Python:如何使ANSI转义码在Windows中也能正常工作?
发布时间:2020-12-20 10:34:11 所属栏目:Python 来源:网络整理
导读:如果我在 linux下的 python中运行它可以工作: start = " 33[1;31m"end = " 33[0;0m"print "File is: " + start + "placeholder" + end 但是,如果我在Windows中运行它不起作用,我怎样才能使ANSI转义码在Windows上运行? 解决方法 您可以检查 Python module
如果我在
linux下的
python中运行它可以工作:
start = " 33[1;31m" end = " 33[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 = " 33[1;31m" end = " 33[0;0m" print "File is: " + start + "<placeholder>" + end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |