def
log(
str, color=
"red"
, background=
"default"
, effect=
"default"):
""" 顏色日誌
# \ 033[顯示方式;字型色;背景色m......[\ 033[0m]
"""# 黑色、紅色、綠色、黃色、藍色、紫紅、靛藍、白色
_color = \
[color]
# 黑色、紅色、綠色、黃色、藍色、紫紅、靛藍、白色
_background_color = \
[background]
# 預設、高亮、下劃線、閃爍、反白、不顯示
_effect = \
[ effect]
print
('\033[%s;%s%sm %s \033[0m!'
%(_effect, _background_color, _color,
str)
)
測試**_color = \
_background_color = \
# 預設、高亮、下劃線、閃爍、反白、不顯示
_effect = \
for color in _color:
for bk in _background_color:
for effect in _effect:
log(
"hello world"
,color=color, background=bk, effect=effect)
效果截圖
Python print格式化輸出
python print格式化輸出 1.格式化輸出整數 python print也支援引數格式化,與c言的printf似,strhello the length of s is d hello world,len hello world print strhello 輸出果 the length o...
python print 內容顏色輸出
print 033 1 30m 字型顏色 白色 033 0m print 033 1 31m 字型顏色 紅色 033 0m print 033 1 32m 字型顏色 深黃色 033 0m print 033 1 33m 字型顏色 淺黃色 033 0m print 033 1 34m 字型顏色 藍色 ...
python print 輸出帶顏色字型
終端的字元顏色是用轉義序列控制的,是文字模式下的系統顯示功能,和具體的語言無關 轉義序列是以esc開頭,即用 033來完成 esc的ascii碼用十進位制表示是27,用八進位制表示就是033 書寫格式 開頭部分 033 顯示方式 前景色 背景色m 結尾部分 033 0m 注意 開頭部分的三個引數 顯...