之前使用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()
补充,在使用colorama时,容易导致赋色字符串后面都是同一颜色的情况,如:

可做如此设置:
str = Fore.RED + " let me see see" + Style.RESET_ALL
即可,
如:


![[python] AES-GCM加解密函数-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2024/12/4a3de68ff9eca0a01bae73a7470170f3.png)


![[python]文本处理-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2023/12/e036ea90943d8195df3aa3e2ad3db122.png)
![[vulsee.com] 使用openpyxl 读取xlsx中的网址链接-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2023/06/92d3798abeb4baabf03ebcf81d50e73e.png)







![[下载] Adobe CS4全集Dreamweaver Flash Photoshop等-微慑信息网-VulSee.com](http://home.pcbeta.com/attachment/200902/15/644959_1234697466Wzi4.jpg)


![[八卦] 王婷婷—揭秘一个大三女生的性爱录像-微慑信息网-VulSee.com](http://free.86hy.com/crack/pic/1.jpg)
![[随笔]今天国际警察节-微慑信息网-VulSee.com](http://photo.sohu.com/20041017/Img222528326.jpg)
青云网
