Issue
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=['Citt\xe0','Veszpr\xe9m','Publicit\xe0']
I need to get a new list that looks like this:
new_list=[u'Citt\xe0',u'Veszpr\xe9m',u'Publicit\xe0']
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?
Solution
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.