Q
Qiangning Hong
u = u'\u554a'Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u554a' in
position 0: ordinal not in range(128)'UTF-8'
Quote from file object's documentation:
encoding
The encoding that this file uses. When Unicode strings are written to
a file, they will be converted to byte strings using this
encoding. .....
So, my question is, as sys.stdout IS a file object, why it does not
use its encoding attribute to convert the given unicode? An
implementation bug? A documenation bug?
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u554a' in
position 0: ordinal not in range(128)'UTF-8'
Quote from file object's documentation:
encoding
The encoding that this file uses. When Unicode strings are written to
a file, they will be converted to byte strings using this
encoding. .....
So, my question is, as sys.stdout IS a file object, why it does not
use its encoding attribute to convert the given unicode? An
implementation bug? A documenation bug?