python中的彩色输出

python中的彩色输出,python,windows,python-2.7,Python,Windows,Python 2.7,我使用的是python 2.7,我已经查看了: 但我还是犯了同样的错误。运行代码为: print '\033[1;31m' + '@%s:' + '[1;m' + '\033[1;32m' + '%s - id = %s\n' + '\033[1;m' % (status.text1.encode('utf-8'), status.text2.encode('utf-8'), status.text3.encode('utf-8')) 得到的误差为: Traceback (most rec

我使用的是python 2.7,我已经查看了:

但我还是犯了同样的错误。运行代码为:

print '\033[1;31m' + '@%s:' + '[1;m' + '\033[1;32m' + '%s - id = %s\n' + '\033[1;m' % (status.text1.encode('utf-8'), status.text2.encode('utf-8'), status.text3.encode('utf-8'))
得到的误差为:

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    mostrar()
  File "C:\Documents and Settings\Administrador.DESKTOP\Mis documentos\test.py", line 16, in mostrar
        print '\033[1;31m' + '@%s:' + '[1;m' + '\033[1;32m' + '%s - id = %s\n' + '\033[1;m' % (status.text1.encode('utf-8'), status.text2.encode('utf-8'), status.text3.encode('utf-8'))
TypeError: not all arguments converted during string formatting
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
莫斯特拉尔()
mostrar中第16行的文件“C:\Documents and Settings\Administrator.DESKTOP\Mis documentos\test.py”
打印'\033[1;31m'+'@%s:'+'[1;m'+'\033[1;32m'+'%s-id=%s\n'+'\033[1;m'(status.text1.encode('utf-8')、status.text2.encode('utf-8')、status.text3.encode('utf-8'))
TypeError:在字符串格式化过程中并非所有参数都已转换
正如您所看到的,我正在windows中使用python


问题是如何避免错误?我已经使用了colorama,错误是相同的。

尝试在要连接的格式字符串周围加上括号。%binds的优先级高于+,因此错误来自:

'\033[1;m' % (... 3 arguments ...)