使用这个一定要注意的是,如果不使用这个pycharm运行的时候,是带有颜色的,但是用pyistaller编译后是没有颜色,所以必须带有下面colorama这个
# pip install colorama from colorama import init init(autoreset=True)
示例:
#如果编译后显示颜色的导入库,解决字体颜色在编译后没有的颜色的办法,必须导入from colorama import init ,init(autoreset=True) # pip install colorama from colorama import init init(autoreset=True) ################ CYAN = ' 33[36m' GREEN = ' 33[32m' YELLOW = ' 33[33m' BLUE = ' 33[34m' RED = ' 33[31m' NORMAL = ' 33[0m' #要以此结尾,还原默认颜色 text = "演示字符串信息12345678" print(text) print( CYAN + text + NORMAL) #青色 print( GREEN + text + NORMAL) #绿色 print( YELLOW + text + NORMAL) #黄色 print( BLUE + text + NORMAL) #蓝色 print( RED + text + NORMAL) #红色 print(GREEN + text[:8] + YELLOW + text[8:] + NORMAL) #绿色 + 黄色 前8个字符是绿色 后面的是黄色 print(RED + text[:8] + BLUE + text[8:] + NORMAL) #绿色 + 黄色



