1. 程式人生 > 其它 >python print 彩色輸出

python print 彩色輸出

技術標籤:Codingprint彩色

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 termcolor