Problem with __str__ method and character encoding
Chris Angelico
rosuav at gmail.com
Fri Dec 7 09:33:44 EST 2012
On Sat, Dec 8, 2012 at 1:14 AM, gialloporpora <gialloporpora at gmail.com> wrote:
>>>> print a
> UnicodeError
>>>> print a.__str__()
> OK
By the way, it's *much* more helpful to copy and paste the actual
error message and output, rather than retyping like that. Spending one
extra minute in the interactive interpreter before you post can save
us all a lot of time and confusion. In this case, what I'm seeing is
(Python 2.6):
>>> print a
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
print a
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 27: ordinal not in range(128)
Which has quite a bit of handy information in it.
ChrisA
More information about the Python-list
mailing list