打印彩色字符串的小包装
colorp的Python项目详细描述
颜色p
这个包是一个小而简单的实用程序,用于在控制台上打印彩色字符串。colorP
支持9种不同的格式样式以及多种前景色和背景色
您可以通过在UNIX终端上发出以下命令来安装它:
sudo pip install -i colorp
用法:
方法:
pPrint(args,text,br=?)
:
args
:是一个dictionary对象,它至少需要s
、fg
或bg
中的一个,并将相应的值定义为字符串。
args={'s':'bold','fg':'red','bg':'white'}
text
:要以给定样式打印的字符串br
:[可选参数:默认值=True
],如果输出后不需要换行符,则可以将其设置为False
。
Eg()
:
- 打印出一些颜色和样式的示例以供用户可视化。
样式和格式:
args
对象决定文本的格式。args
中的每个键都可以是某些预定义值之一。它们如下所示:'s'
:文本样式
Value | Description |
---|---|
^{ | Formats the text as plain text |
^{ | Bolds the text |
^{ | Dims the text |
^{ | Italicizes the text |
^{ | Underlines the text |
^{ | Blinks the text repeatedly |
^{ | Swaps foreground and background values |
^{ | Hides the text on display |
^{ | Strikes off the desired text |
'fg'
:字体颜色
Value |
---|
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
'bg'
:背景色
Value |
---|
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
^{ |
注意:
'bg'
与'fg'
具有相同的可能值。