【发布时间】:2019-03-06 15:52:29
【问题描述】:
当我尝试在 python 输入语句中使用 colorama 时,它不起作用。这是我得到的输出:
[33mEnter the name of the AWS account you'll be working in:
它显示 ASCII 码而不是使用我想要的颜色。而且不会变色。
这是我的代码:
from colorama import init, Fore, Back, Style
init()
input(Fore.YELLOW + "Enter the name of the AWS account you'll be working in: ")
有什么办法可以让它工作吗?
我在 Windows 10 上运行我的环境。如果可能的话,我想要一个跨平台解决方案,因为其他人可能会在 linux 上运行它。
【问题讨论】:
-
可能是您的环境...您在其中运行它的控制台?也许它不支持通过这些代码进行着色。 colorama 模块所做的只是输出正确的字符以在其他地方解释。 python 代码之外的东西必须监视这些字符并将文本转换为没有代码的彩色文本。