[英]Colorama outputs random things
我正在使用colorama
为我的终端着色。 我有一个自动更新程序,我把它上色了。 如果我把它编译成一个 exe,我得到的输出是:
←[36mYour ←[34mVersion ←[36mis Old!
press enter to Update the Application to v0.0.2.2...
根本没有颜色。 我认为这是一个错误,因为如果我不将其编译为 exe,它就可以工作。
这是我的代码:
print(f"{Fore.CYAN}Your {Fore.BLUE}Version {Fore.CYAN}is Old!\n"
f"press enter to Update the Application to {updatecheck}...")
首先,我列出了所有颜色,随机选择颜色
(color_random) 在代码中:随机选择颜色
你应该阅读colorama的例子
import random
from colorama import init, Fore, Style
init()
color_list = [Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.CYAN, Fore.WHITE]
color_random = random.choice(color_list)
updatecheck = "v0.0.2.2..."
print(Fore.CYAN+" your", Fore.BLUE+"Version", Fore.CYAN+"is Old!\n",
Style.RESET_ALL, "press enter to Update the Application to", color_random+updatecheck, Style.RESET_ALL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.