[docs] [issue20686] Confusing statement about unicode strings in tutorial introduction

R. David Murray report at bugs.python.org
Thu Mar 20 14:12:04 CET 2014


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 at bugs.python.org>
<http://bugs.python.org/issue20686>
_______________________________________


More information about the docs mailing list