Python print输出彩色字符的方法,pythonprint,Python print
Python print输出彩色字符的方法,pythonprint,Python print
Python print输出彩色字符的方法,声明,代码没测试过。只是感觉很酷就拿来分享下,赚个积分。
shell里面显示字符串有时候是彩色的,python的都很单调,现在python的print也可以实现相同的输出。
#!/usr/bin/env python#-*-coding:utf-8-*-"""0 All attributes off 默认值1 Bold (or Bright) 粗体 or 高亮4 Underline 下划线5 Blink 闪烁7 Invert 反显30 Black text31 Red text32 Green text33 Yellow text34 Blue text35 Purple text36 Cyan text37 White text40 Black background41 Red background42 Green background43 Yellow background44 Blue background45 Purple background46 Cyan background47 White background"""def main(): """ """for atrr in [0,1,4,5,7]: print "attribute %d ------------------------------" % atrr for fore in [30,31,32,33,34,35,36,37]: for back in [40,41,42,43,44,45,46,47]: color = "\x1B[%d;%d;%dm" % (atrr,fore,back) print "%s %d-%d-%d\x1B[0m" % (color,atrr,fore,back), print ""if __name__ == "__main__": """ """ main()
编橙之家文章,
相关内容
- 依赖Tkinter完成的简单记事本,依赖tkinter记事本,这是我
- 控制台进度自动刷新python方法源码,自动刷新python,要实
- 导出Gmail、网易邮箱联系人名单的python方法,gmailpytho
- 在CSV文件中添加联系人的python方法,csvpython,学习Pytho
- Python Flask方法实现Whois域名查询功能,flaskwhois,Python F
- 用python sched模块周期抓取论坛在线人线示例,pythonsch
- Python方法调用网站接口实现MD5值查询,pythonmd5,这是在
- Python对多线程数量的限制方法,python多线程数量,当你在
- 一个简易的hash加密小工具源码,hash加密源码,一直喜欢
- 计算前一个月最后一天日期的python方法,最后一天pyt
评论关闭