python——print

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

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

例:

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

输出结果:

print输出时不换行:

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

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

例:

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

输出结果:

hello
原文地址:https://www.cnblogs.com/ChenYi0919/p/9288659.html