python实现控制台打印
2017-08-16 10:23
190 查看
python实现控制台打印
#!/usr/bin/env python import os import sys class CConsole: M_MAP_COLOR = {\ 'COLOR_BLACK' : "\033[0;30m", 'COLOR_RED' : "\033[0;31m", 'COLOR_GREEN' : "\033[0;32m", 'COLOR_YELLOW' : "\033[0;33m", 'COLOR_BLUE' : "\033[0;34m", 'COLOR_PUPPLE' : "\033[0;35m", 'COLOR_CYAN' : "\033[0;36m", 'COLOR_WHITE' : "\033[0;37m", 'COLOR_RESTORE' : "\033[0m", } @staticmethod def ColorPrint(strPrint, strColor = None): strPrint = str(strPrint) if strColor in CConsole.M_MAP_COLOR.keys(): strMsg = CConsole.M_MAP_COLOR[strColor] + strPrint + CConsole.M_MAP_COLOR['COLOR_RESTORE'] else: strMsg = strPrint print(strMsg) sys.stdout.flush()
相关文章推荐
- Python使用logging模块实现打印log到指定文件的方法
- ajax前后台交互入门例子实现控制台打印结果
- Python实现控制台输入密码的方法
- C++/Php/Python/Shell 程序按行读取文件或者控制台的实现
- 面试题:100个小朋友围在一起,设定编号为1~100,依次按1,2,3,4,5,6,7,8,9循环报数,报到9的小朋友出圈,请写代码打印各个小朋友的出圈顺序?(Python实现)
- Python实现不同格式打印九九乘法表
- 利用Python实现打印花图案
- python 实现树结构的打印
- 普元EOS 命名sql中控制台打印实现方法(拦截器实现方法)
- python实现在控制台输入密码不显示的方法
- Python实现打印汉字
- python控制台中实现进度条功能
- python3实现打印乘法口诀表
- 打印100以内的素数(质数)----C++实现、python实现
- 利用Js的console对象,在控制台打印调式信息测试Js的实现
- 使用shell和python分别实现简单菜单功能--打印当前系统状态信息
- 小明去美国旅游,美国温度以华氏温度计量,她需要将华氏温度转换为摄氏温度,编写程序实现此功能. 要求: 从控制台输入华氏温度信息,并且分别打印最后的华氏温度和摄氏温度的结果
- Windows搭建Python开发环境,实现Hello World 的打印