如果我在 Linux 下的 python中运行它可以工作:
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
查看更多关于Python:如何使ANSI转义码在Windows中也能正常工作?的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did171284