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?
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?
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?
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?