python输出内容高亮
python,输出,内容,高亮
2025-04-11 08:57:57 时间
文章最后更新时间为:2018年12月21日 20:51:52
因为需要美化脚本在网上看到的, 搬过来以后有需要直接copy美滋滋...
copy自https://blog.csdn.net/qianghaohao/article/details/52117082?utm_source=blogxgwz2
# -----------------colorama模块的一些常量---------------------------
# Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
# Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
# Style: DIM, NORMAL, BRIGHT, RESET_ALL
#
from colorama import init, Fore, Back, Style
init(autoreset=True)
class Colored(object):
# 前景色:红色 背景色:默认
def red(self, s):
return Fore.RED + s + Fore.RESET
# 前景色:绿色 背景色:默认
def green(self, s):
return Fore.GREEN + s + Fore.RESET
# 前景色:黄色 背景色:默认
def yellow(self, s):
return Fore.YELLOW + s + Fore.RESET
# 前景色:蓝色 背景色:默认
def blue(self, s):
return Fore.BLUE + s + Fore.RESET
# 前景色:洋红色 背景色:默认
def magenta(self, s):
return Fore.MAGENTA + s + Fore.RESET
# 前景色:青色 背景色:默认
def cyan(self, s):
return Fore.CYAN + s + Fore.RESET
# 前景色:白色 背景色:默认
def white(self, s):
return Fore.WHITE + s + Fore.RESET
# 前景色:黑色 背景色:默认
def black(self, s):
return Fore.BLACK
# 前景色:白色 背景色:绿色
def white_green(self, s):
return Fore.WHITE + Back.GREEN + s + Fore.RESET + Back.RESET
color = Colored()
print(color.red('I am red!'))
print (color.green('I am gree!'))
print (color.yellow('I am yellow!'))
print (color.blue('I am blue!'))
print (color.magenta('I am magenta!'))
print (color.cyan('I am cyan!'))
print (color.white('I am white!'))
print (color.white_green('I am white green!'))
SHOW:
相关文章
- python中griddata的外插值_利用griddata进行二维插值
- 记一次python清洗疫情历史数据
- 【Python】QQ查IP工具
- 自动化神器!Python 批量读取身份证信息写入 Excel
- python 关键字「建议收藏」
- win10下python环境变量设置
- 不用学Python的自动化办公 确定不来看看?
- python中的pop函数和append函数
- python中cPickle用法「建议收藏」
- Python中的/与//的区别
- python自带的排列组合函数
- python使用matplotlib绘图 — barChart
- Python中的语法糖甜不甜?
- python的优缺点
- Python源码保护[通俗易懂]
- Python数字图像处理-3种图像读取方式总结
- python中的取整
- Python-基础01-变量
- [Python从零到壹] 十六.文本挖掘之词云热点与LDA主题分布分析万字详解
- aic准则python_Python数据科学:线性回归