python控制台着色
python-termstyle的Python项目详细描述
术语样式
termstyle是一个简单的python库,用于向 终端(控制台)程序。定义来自ECMA-048, “编码字符集的控制功能”标准
示例用法:
from termstyle import * print "%s:%s" % (red('Hey'), green('how are you?')) print blue('How ', bold('you'), ' doin?')
或者,您可以使用颜色作为字符串:
print "%sBlue!%s" % (blue, reset)
款式:
reset or default (no colour / style)
颜色:
black red green yellow blue magenta cyan white
背景色:
bg_black bg_red bg_green bg_yellow bg_blue bg_magenta bg_cyan bg_white bg_default
在支持透明性的终端中,bg_default通常用于设置 背景为透明[1]。
重量:
bold inverted
款式:
italic underscore
控制:
auto() - sets colouring on only if sys.stdout is a terminal disabe() - disable colours enable() - enable colours
[1] | Supporting terminals include rxvt-unicode, and Eterm. |