如果我在 linux下的 python中运行它可以工作: start = "\033[1;31m"end = "\033[0;0m"print "File is: " + start + "placeholder" + end 但是,如果我在Windows中运行它不起作用,我怎样才能使ANSI转义码在Windows上运
start = "\033[1;31m" end = "\033[0;0m" print "File is: " + start + "<placeholder>" + end
但是,如果我在Windows中运行它不起作用,我怎样才能使ANSI转义码在Windows上运行?
您可以检查 Python module to enable ANSI colors for stdout on Windows?以查看它是否有用.colorama模块似乎是跨平台的.
你安装colorama:
pip install colorama
然后:
import colorama colorama.init() start = "\033[1;31m" end = "\033[0;0m" print "File is: " + start + "<placeholder>" + end