python在控制台终端打印彩色文字,python控制台终端,from coloram
文章由Byrx.net分享于2019-03-23 11:03:39
python在控制台终端打印彩色文字,python控制台终端,from coloram
from colorama import Fore, Styleimport sysclass Highlight: def __init__(self, clazz, color): self.color = color self.clazz = clazz def __enter__(self): print(self.color, end="") def __exit__(self, type, value, traceback): if self.dings == Fore: print(Fore.RESET, end="") else: assert self.dings == Style print(Style.RESET_ALL, end="") sys.stdout.flush()with Highlight(Fore, Fore.GREEN): print("this is highlighted")print("this is not")
评论关闭