色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

Python通過2種方法輸出帶顏色字體

瀏覽:82日期:2022-08-04 16:47:10

方法1:

使用Python中自帶的print輸出帶有顏色或者背景的字符串

書寫語法

print(033[顯示方式;前景色;背景色m輸出內(nèi)容033[0m)

其中,顯示方式、前景色、背景色都是可選參數(shù)(可缺省一個或多個)。

參數(shù)

顯示方式

顯示方式 效果 0 默認(rèn) 1 粗體 4 下劃線 5 閃爍 7 反白顯示

print('顯示方式:')print('033[0mSuixinBlog: https://suixinblog.cn033[0m')print('033[1mSuixinBlog: https://suixinblog.cn033[0m')print('033[4mSuixinBlog: https://suixinblog.cn033[0m')print('033[5mSuixinBlog: https://suixinblog.cn033[0m')print('033[7mSuixinBlog: https://suixinblog.cn033[0m')

Python通過2種方法輸出帶顏色字體

顏色

字體色編號 背景色編號 顏色 30 40 黑色 31 41 紅色 32 42 綠色 33 43 黃色 34 44 藍(lán)色 35 45 紫色 36 46 青色 37 47 白色

print('字體色:')print('033[30mSuixinBlog: https://suixinblog.cn033[0m')print('033[31mSuixinBlog: https://suixinblog.cn033[0m')print('033[32mSuixinBlog: https://suixinblog.cn033[0m')print('033[4;33mSuixinBlog: https://suixinblog.cn033[0m')print('033[34mSuixinBlog: https://suixinblog.cn033[0m')print('033[1;35mSuixinBlog: https://suixinblog.cn033[0m')print('033[4;36mSuixinBlog: https://suixinblog.cn033[0m')print('033[37mSuixinBlog: https://suixinblog.cn033[0m')print('背景色:')print('033[1;37;40mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;41mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;42mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;43mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;44mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;45mtSuixinBlog: https://suixinblog.cn033[0m')print('033[37;46mtSuixinBlog: https://suixinblog.cn033[0m')print('033[1;30;47mtSuixinBlog: https://suixinblog.cn033[0m')

Python通過2種方法輸出帶顏色字體

方法2:

colorama是一個python專門用來在控制臺、命令行輸出彩色文字的模塊,可以跨平臺使用。

1. 安裝colorama模塊

pip install colorama

可用格式常數(shù):

Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.Style: DIM, NORMAL, BRIGHT, RESET_ALL

跨平臺印刷彩色文本可以使用彩色光的常數(shù)簡稱ANSI轉(zhuǎn)義序列:

from colorama import Fore,Back,Styleprint (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!!')

Init關(guān)鍵字參數(shù):

init()接受一些* * kwargs覆蓋缺省行為

init(autoreset = False):

如果你發(fā)現(xiàn)自己一再發(fā)送重置序列結(jié)束時關(guān)閉顏色變化每一個打印,然后init(autoreset = True)將自動化示例:

from colorama import init,Foreinit(autoreset=True)print (Fore.RED + 'welcome to python !!')print ('automatically back to default color again')

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 中文字幕一区二区小泽玛利亚 | 亚洲成人在线免费观看 | 99re7在线精品免费视频 | 三级视频网站在线观看播放 | 在线播放高清国语自产拍免费 | 久久男人的天堂色偷偷 | a级日韩乱理伦片在线观看 a级特黄毛片免费观看 | 黄色三级三级三级 | 国产精品久久久久久搜索 | 久久精品国产精品青草不卡 | 国产高清美女一级毛片久久 | 欧美成人老熟妇暴潮毛片 | 久草视频福利在线观看 | 91精品啪在线看国产网站 | 日本a级毛片视频播放 | 欧美日韩亚洲一区二区三区 | 欧美高清在线视频一区二区 | 亚欧美视频| 国内精品久久久久影院免费 | 国产精品videossex另类 | 国产 magnet | 久草资源在线观看 | 欧美一区二区三区播放 | 国产高清视频免费观看 | 欧美aaaa在线观看视频免费 | 亚洲成人免费网站 | 手机av在线播放 | 欧美在线bdsm调教一区 | 久久99精品久久久久久秒播 | 亚洲一级视频在线观看 | 97视频在线观看免费视频 | 视频一区久久 | 狠狠干香蕉 | 久久精品精品 | 亚洲精品天堂在线观看 | 成人在线一区二区三区 | 免费视频一区二区 | 欧美一级毛片欧美一级 | 国产伦精一区二区三区视频 | 国产精品毛片在线大全 | 农村寡妇女人一级毛片 |