我的问题很明确。如何使用 python 设置控制台的背景颜色? 我知道我们可以在 C# 中设置控制台的背景颜色。 所以我认为python也可以做到。 但是怎么办? 我在 Windows 上,我使用 python 2.7.3。 谢谢...
请您参考如下方法:
您可以使用 the color command 设置 Windows cmd 控制台颜色,通过 os.system 从 Python 传递它:
>>> import os
>>> os.system('color 1f') # sets the background to blue
对于 Linux 终端,使用 the setterm command :
>>> import os
>>> os.system('setterm -background white -foreground white -store')
