Why does Python output a string and a unicode of the same value differently?

Posted by Thierry Lam on Stack Overflow See other posts from Stack Overflow or by Thierry Lam
Published on 2010-05-06T15:03:59Z Indexed on 2010/05/06 15:08 UTC
Read the original article Hit count: 500

Filed under:

I'm using Python 2.6.5 and when I run the following in the Python shell, I get:

>>> print u'Andr\xc3\xa9'
André
>>> print 'Andr\xc3\xa9'
André
>>>

What's the explanation for the above? Given u'Andr\xc3\xa9', how can I display the above value properly in an html page so that it shows André instead of André?

© Stack Overflow or respective owner

Related posts about python