如何打印彩色文本? (蟒蛇 3)

时间:2021-01-14 18:50:02

标签: python python-3.x

print("this text is blue")

如何将文本设为蓝色? 我有:

print('\033[94m' + "this text is blue")

print("\033[94mthistextisblue")

然而,到目前为止,一切都没有奏效。

1 个答案:

答案 0 :(得分:0)

最好的方法是使用 colorama 模块!

https://pypi.org/project/colorama/

https://github.com/tartley/colorama

它与所有操作系统兼容。它易于使用且比手动执行所有这些特殊/退出等字符要安全得多