In Python, Unicode behaves a bit like Midas, the character in Greek legend who turned everything he touched (including his daughter) into gold. When you use a Unicode string and a regular string together, the results are always Unicode.
>>> myunicodestring = u"Midas is coming! " >>> mystring = "Don't touch me, Midas!" >>> myunicodestring + mystring u"Midas is coming! Don't touch me, Midas!"
This example shows the difference between the encoded and decoded strings.
• Encoded string
• Decoded (Unicode) string
\xe9 is Python's shorthand way of representing Unicode character \u00e9, which prints as é.
Both strings look the same when printed:
Was this article helpful?