篇首语:本文由小编为大家整理,主要介绍了python终端彩色打印(termcolor)相关的知识,希望对你有一定的参考价值。
Quick method for creating coloured tty in python terminal using 'termcolor'$ pip install termcolor;
try:
import termcolor
from termcolor import colored
except: print "No colours :("
def p(*args, **kargs):
color = kargs.get("color", None)
if color and termcolor:
for x in args:
sys.stdout.write(colored(x, color) + "")
else:
sys.stdout.write(*args)
以上是关于python终端彩色打印(termcolor)的主要内容,如果未能解决你的问题,请参考以下文章