print显示设置

显示颜色格式:\033[显示方式;字体色;背景色m......[\033[0m]

-------------------------------------------
-------------------------------------------
字体色     |       背景色     |      颜色描述
-------------------------------------------
       |        40       |       黑色
       |        41       |       红色
       |        42       |       绿色
       |        43       |       黃色
       |        44       |       蓝色
       |        45       |       紫红色
       |        46       |       青蓝色
       |        47       |       白色
-------------------------------------------
-------------------------------
显示方式     |      效果
-------------------------------
   0      |     终端默认设置
   1      |     高亮显示
   4      |     使用下划线
   5      |     闪烁
   7      |     反白显示
   8      |     不可见
-------------------------------

 

例:python

print('This is a \033[1;35m test \033[0m!')
print('This is a \033[1;32;43m test \033[0m!')
print('\033[1;33;44mThis is a test !\033[0m')

输出:字体

 

print输出时不换行:

若是 python是2.x版本,在语句后加一个英文的逗号 ,
print x,

若是 python是3.x 版本 print不换行参数 end=""
print(x, end="")

例:blog

print('he'
      ''   #中间回车键换行
      ''
      ''
      'llo jacky',end='')

输出:class

hello jacky