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')
另一个选项,使用termcolor:
from termcolor import colored
print colored('hello', 'red'), colored('world', 'green')
http://pypi.python.org/pypi/colorama
可能是最好的
请看一下问题的答案:
如果无法安装附加模块,可以尝试使用 直接使用ANSI序列。请注意,该方法不可移植, 最好使用一些特殊的模块。
当您需要更强大的功能时,我建议您使用
colorama
(pypi.python.org/pypi/colorama):另一个选项,使用
termcolor
:相关问题 更多 >
编程相关推荐