pipeline encoding

Tomasz Toczyski tt at praterm.com.pl
Thu Dec 6 12:13:04 EST 2007


My locale is set to UTF-8. The command:
python -c "print u'\u03A9'"
gives me the desired result and doesn't produce any error.

But when I want to redirect the output to a file I invoke:
python -c "print u'\u03A9'" > file.txt
I get an error:

File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03a9' in 
position 0: ordinal not in range(128)

How to cope with it?

-tt.



More information about the Python-list mailing list