【发布时间】:2018-09-27 08:19:59
【问题描述】:
我还有一个关于 Windows cmd 的小控制台程序的问题。
我使用 colorama 为终端中的文本着色,使其看起来像这样:
然后我发现了如何在input()-method 中使用一点“hack”为文本着色,并使用不带换行符的打印,如下所示:
from colorama import init
init(autoreset=True)
YELLOW = "\x1b[1;33;40m"
print(f"\n{YELLOW}Turnier spielen? [T]: ", end='')
tournament = input()
这会导致上图中的黄线。
但我仍在寻找一种方法来为用户输入的字符着色 - 所以在这里我想将用户输入的“sdffdgf ...”格式化为彩色。
有没有人为我提供解决方案,或者使用有限的 windows cmd 无法解决?
【问题讨论】:
标签: python formatting colorama