问题描述
使用此代码时:
from termcolor2 import colored
print(colored('hello','red'),colored('world','green'))
我在终端的输出是:←[31mhello←[0m ←[32mworld←[0m
有什么问题吗?
解决方法
您可以使用 colorama
模块
pip install colorama
代码:
from colorama import init,Fore,Back
init(convert=True) # Initialize colorama module
print(Fore.RED + 'Your Text' + Fore.RESET) # Red colored output
print(Back.GREEN + 'Your Text' + Back.RESET) # Green Backgroung Output