如下所示:

#!/usr/bin/env python
import os
import sys
class CConsole:
M_MAP_COLOR = {\
'COLOR_BLACK' : "\033[0;30m",
'COLOR_RED' : "\033[0;31m",
'COLOR_GREEN' : "\033[0;32m",
'COLOR_YELLOW' : "\033[0;33m",
'COLOR_BLUE' : "\033[0;34m",
'COLOR_PUPPLE' : "\033[0;35m",
'COLOR_CYAN' : "\033[0;36m",
'COLOR_WHITE' : "\033[0;37m",
'COLOR_RESTORE' : "\033[0m",
}
@staticmethod
def ColorPrint(strPrint, strColor = None):
strPrint = str(strPrint)
if strColor in CConsole.M_MAP_COLOR.keys():
strMsg = CConsole.M_MAP_COLOR[strColor] + strPrint + CConsole.M_MAP_COLOR['COLOR_RESTORE']
else:
strMsg = strPrint
print(strMsg)
sys.stdout.flush()
標(biāo)題名稱:python實(shí)現(xiàn)控制臺(tái)打印的方法-創(chuàng)新互聯(lián)
分享地址:http://www.chinadenli.net/article32/dsoopc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、全網(wǎng)營(yíng)銷推廣、電子商務(wù)、軟件開發(fā)、品牌網(wǎng)站設(shè)計(jì)、App設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容