Reputation: 10162
I am playing around working with unicode
in python.
I am not able to print (display)
the unicode characters
such asé
I tried the following:
>>> sys.setdefaultencoding('UTF8')
>>> chr(0xFF)
'\xff'
>>> u = u'abcdé'
>>> len(u)
5
>>> u[4]
u'\xe9'
>>> str(u[4])
'\xc3\xa9'
>>>
I was expecting u[4]
to print é
but it prints u'\xe9'
. how can I make this work?
I am using python 2.7.2 version
Upvotes: 1
Views: 203
Reputation: 9904
When you just type u[4]
, it shows the repr. To see the unicode character, use print.
print u[4]
Upvotes: 6