简介
Python的Colorama模块,可以跨多终端,显示字体不同的颜色和背景,只需要导入colorama模块即可,不用再每次都像linux一样指定颜色。
1. 安装colorama模块
pip install colorama
2. 常用格式常数
Fore是针对字体颜色,Back是针对字体背景颜色,Style是针对字体格式

注意,颜色RED,GREEN都需要大写,先指定是颜色和样式是针对字体还是字体背景,然后再添加颜色,颜色就是英文单词指定的颜色

输出结果


3.Init关键字参数:
init()接受一些* * kwargs覆盖缺省行为,
autoreset是自动恢复到默认颜色
init(autoreset = False):
init(wrap=True):The default behaviour is to convert if on Windows and output is to a tty (terminal).
在windows系统终端输出颜色要使用init(wrap=True)

输出结果


4.使用实例

网友评论