Python converting a list of strings to unicode

Question:

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.

 list=['Cittxe0','Veszprxe9m','Publicitxe0']

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

 new_list=[u'Cittxe0',u'Veszprxe9m',u'Publicitxe0']

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?

Asked By: CosimoCD

||

Answers:

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?

Answered By: obayhan
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.