只是另一个模块打印256色的字符串在终端。
string-color的Python项目详细描述
字符串颜色
string color只是另一个python模块,用于在print语句中为字符串着色。
安装
$ pip install string-color
cli用法
positional arguments:
color show infor for a specific color:
$ string-color red
$ string-color '#ffff87'
$ string-color *grey* # wildcards acceptable
optional arguments:
-h, --help show this help message and exit
-x, --hex show hex values
-r, --rgb show rgb values
--hsl show hsl values
-a, --alpha sort by name
-v, --version show program's version number and exit
$ string-color
显示所有256色的列表
$ string-color yellow
显示黄色的颜色信息
$ string-color "#ff0000"
显示十六进制值ff0000的颜色信息
$ string-color *grey*
显示名称中带有“灰色”的所有颜色。也适用于“灰色*”和“*灰色”
python模块使用
fromstringcolorimportcs,bold,underline# a few examples without background colors. # for color names see CLI usage above. print(cs("here we go","orchid"))print(cs("away to space!","DeepPink3"))print(cs("final fantasy","#ffff87"))# bold and underline also available. print(bold(cs("purple number 4, bold","purple4")))print(underline(cs("blue, underlined","blue")))print(bold(underline(cs("bold AND underlined!","gold"))))# yellow text with a red background. # color names, hex values, and ansi numbers will work. print(cs("warning!","yellow","#ff0000"))