# corlorama 中 Style.RESET 用法示例
1 # corlorama 中 Style.RESET 用法示例 2 3 #import colorama # 调用每个成员前必须加上colorama. 4 from colorama import init, Fore, Back, Style 5 6 # 初始化 colorama(Windows 系统必需) 7 init() 8 # init(autoreset=True) # 每次 print 后自动重置 9 10 # 示例1:基本用法 11 print(Fore.RED + "红色文本" + Style.RESET_ALL + " 默认文本") # 输出后重置样式 12 13 # 示例2:组合前景色、背景色和样式 14 print(Fore.YELLOW + Back.BLUE + Style.BRIGHT + "黄色文本,蓝色背景,加粗" + Style.RESET_ALL) 15 print("默认样式(无颜色/样式)") # 确保不受前文影响 16 17 # 示例3:自动重置(通过 init(autoreset=True)) 18 init(autoreset=True) # 每次 print 后自动重置 19 print(Fore.GREEN + "绿色文本") # 输出后自动重置 20 print("默认文本") # 直接输出,无需手动重置