\033[1;31;40m # 1是显示方式(可选),31是字体颜色,40m 是字体背景颜色;
\033[0m # 恢复终端默认颜色,即取消颜色设置;
# !/usr/bin/env python # -*- coding: utf-8 -*- # 字体颜色 print " =====字体颜色====== " for i in range(31, 38 ): print " \033[%s;40mHello world!\033[0m " % i # 背景颜色 print " =====背景颜色====== " for i in range(41, 48 ): print " \033[47;%smHello world!\033[0m " % i # 显示方式 print " =====显示方式====== " for i in range(1, 9 ): print " \033[%s;31;40mHello world!\033[0m " %i
-------------------------------------------------------------
转载请保留此段声明,且在文章页面明显位置给出原文链接,谢谢!
------------------------------------------------------------------------------
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个 “推荐”哦,博主在此感谢!
------------------------------------------------------------------------------