和colorama不同的地方,是可以单独指定某些字的颜色;
特性
- disable(),忽略所有颜色调用
- normal(), 重置为默认
- 只在TTY显示颜色
- colorama驱动
可用的颜色:
red, green, yellow, blue, black, magenta, cyan, white, 和 normal,clean,disable
实例
>>> import crayons
>>> print(crayons.red('red string'))
>>> print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))
>>> crayons.disable()
>>> print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))
>>> crayons.DISABLE_COLOR = False
>>> print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))
>>> print(crayons.red('red string'), bold = True)

3926

被折叠的 条评论
为什么被折叠?



