
March 20, 2014
1:12 p.m.
R. David Murray added the comment: re: file. You forgot the 'u' in front of the string:
f.write(u'This is a «test»\n') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode character u'\xab' in position 10: ordinal not in range(128)
So you were actually writing binary in your console encoding, which must have been utf-8. (This kind of confusion is the main reason python3 exists). ---------- title: Confusing statement -> Confusing statement about unicode strings in tutorial introduction _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20686> _______________________________________