【发布时间】:2018-09-30 09:57:51
【问题描述】:
如何使用 python 在终端中以 ansi 颜色打印文本? 我有这段代码来测试一下什么代码对文字有什么影响:
for i in range(0, 55):
print(f"\033[{i}mAt {i} THIS happens! \033[0m")
但我看到的只是:
←[0mAt 0 THIS happens! ←[0m
←[1mAt 1 THIS happens! ←[0m
←[2mAt 2 THIS happens! ←[0m
←[3mAt 3 THIS happens! ←[0m
←[4mAt 4 THIS happens! ←[0m
...
It works as intended in the online editor repl.it.
我知道主题设置中有terminal.ansi 颜色,但我如何访问它们?
【问题讨论】:
标签: python python-3.x visual-studio-code ansi