我正在寻找可以在 Windows 下添加 ANSI 支持的 Python 模块.
I am looking for a Python module that would add ANSI support under Windows.
这意味着导入模块后,如果你输出ANSI转义字符串,它们会相应出现.
This means that after importing the module, if you output ANSI escaped strings, they will appear accordingly.
有两个 python 模块可以做到这一点 colorama
和 tendo.ansiterm
模块,最初是为 编写的waf
.
There are two python modules that are able to do this colorama
and tendo.ansiterm
module, which was originally written for waf
.
初步测试表明 colorama
更加成熟,即使它需要两行代码而不是一行.
By initial tests indicate that colorama
is more mature, even if it requires two lines of code instead of one.
import sys
try:
import colorama
colorama.init()
except:
try:
import tendo.ansiterm
except:
pass
sys.stdout.write"