Tuesday 15 May 2012

windows - Colored output in python -



windows - Colored output in python -

i'm using python 2.7 , in:

print in terminal colors using python?

python terminal menu? terminal coloring? terminal progress display?

and still getting same error. running code is:

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'))

and error obatained is:

traceback (most recent phone call last): file "<pyshell#4>", line 1, in <module> mostrar() file "c:\documents , 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 arguments converted during string formatting

like can see, i'm using python in windows.

the question how avoid error? utilize colorama, , error same.

try putting parentheses around format strings concatenating. % binds higher precedence +, error comes from:

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

python windows python-2.7

No comments:

Post a Comment