Update on 3-16, I find a more convienient packaged named colorama
,
the more detailed usage please visit Python常用模块—— Colorama模块
from termcolor import colored
print(colored('text string','red'))
An example:
from termcolor import colored
import sys
print(colored('sys.path=','yellow'))
print(sys.path)
在termcolor的源码中,可以找到可用的颜色:
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
在使用termcolor之前,需要使用pip安装termcolor
pip install