国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

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

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

方法1:

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

書寫語法

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

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

參數

顯示方式

顯示方式 效果 0 默認 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 藍色 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

可用格式常數:

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

跨平臺印刷彩色文本可以使用彩色光的常數簡稱ANSI轉義序列:

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關鍵字參數:

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

init(autoreset = False):

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

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

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 99久久一区 | 一本色道久久综合亚洲精品 | 99re热在线视频 | 男女男精品视频网站 | 亚洲欧美日韩国产制服另类 | 亚洲欧美中文日韩在线v日本 | 欧美一级特黄刺激爽大片 | 美国毛片一级 | 亚洲精品二区 | 亚洲欧洲日韩综合色天使不卡 | 精品九九视频 | 亚洲三级黄色 | 亚洲日本aⅴ片在线观看香蕉 | 久草a在线 | 黄色三级视频在线播放 | 欧美成人午夜免费完成 | yellow中文字幕久久网 | 怡红院在线视频全部观看 | 国产精品久久网 | 一级成人毛片免费观看欧美 | 国产成人精品高清不卡在线 | 国产亚洲精品91 | 欧美一区二区三区久久久人妖 | 国产精品合集久久久久青苹果 | 亚洲精品美女视频 | 亚洲欧洲国产视频 | 精品久久香蕉国产线看观看亚洲 | 国产成人经典三级在线观看 | 99久久免费观看 | 欧美xo影院 | 日韩在线高清视频 | 久久久综合结合狠狠狠97色 | 亚洲免费视频观看 | 亚洲视频在线观看免费视频 | 国产午夜亚洲精品国产 | 在线精品一区二区三区 | 一道精品视频一区二区三区图片 | 亚洲夜色| 久久久国产精品网站 | 欧美一级大黄特黄毛片视频 | 亚洲欧洲日产国码一级毛片 |