Cosimo Curiale Cosimo Curiale - 1 year ago 86
Python Question

Python converting a list of strings to unicode

I have a list of strings that originally was a list of unicode element. And so, some string contains some character accent in unicode formate.


I need to get a new list that looks like this:


Each element of the new_list has to carry both the u and the accent.
Is there a way to do it iterating on each element?

Answer Source
new_list=[unicode(repr(word)) for word in old_list]

>>> print new_list 
[u"'Citt\\xe0'", u"'Hello'", u"'Publicit\\xe0'"]

Is that what you want?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download