之前使用termcolor,最近看到有colorama,发现更加简单。。
1、termcolor
from termcolor import colored, cprint
str = colored(str(mTypeName), 'red','on_white',attrs=None)
2、colorama
from colorama import Fore,Back,Style,init
def main():
#init(autoreset=True)
print(Style.RESET_ALL)
str = Fore.RED + " let me see see"
print (str)
print (Fore.WHITE +"let me see see")
if __name__ == '__main__':
main()
拓展阅读(点评/知识):
Python基础教程 Colorama模块 https://zhuanlan.zhihu.com/p/76954975
本文标题: | [python] 输出颜色 – colorama / termcolor |
本文链接: (转载请附上本文链接) | https://vulsee.com/archives/vulsee_2023/0911_16967.html |