colorama: 跨终端控制字体和背景颜色的 Python 库

2020-12-13  本文已影响0人  星塵子

安装

pip install colorama

Fore 字体颜色 :

BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET

Back 字体背景色:

BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET

Style 字体格式:

DIM, NORMAL, BRIGHT, RESET_ALL

值需大写

from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

init(autoreset=True) 自动恢复到默认颜色

上一篇下一篇

猜你喜欢

热点阅读