print() sends it's data to stdout which encodes the data based on it's
own encoding. If you want to change this behavior, replace sys.stdout
with your own io.TextIOWrapper with 'replace' as the errors argument.
--
Cheers,
Benjamin Peterson
"There's nothing quite as beautiful as an oboe... except a chicken
stuck in a vacuum cleaner."
_______________________________________________
Python-3000 mailing list
Pytho...@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: http://mail.python.org/mailman/options/python-3000/python-3000-garchive-63646%40googlegroups.com
You are using it in a wrong way. The terminal window, on Windows, does
not use the "mbcs" encoding. Microsoft has two system encodings: the
"ANSI" code page (CP_ACP), called "mbcs" by Python, and the "OEM" code
page (CP_OEMCP). The latter is what the terminal window uses. Python
does not directly expose the Microsoft OEMCP codec; instead, it
determines the terminal's code page, and then carries its own codec for
that code page ("gbk" in your case).
To make your example work, replace "mbcs" with sys.stdout.encoding.
HTH,
Martin