0

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?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
CosimoCD
  • 3,570
  • 3
  • 22
  • 31
  • If your original list was of Unicode strings, show the code that resulted in your byte string list and we can show you how to get the correct result without having to "correct" it. – Mark Tolonen Nov 26 '16 at 03:53

1 Answers1

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

obayhan
  • 1,636
  • 18
  • 35
  • Hello obayhan! Is there a way to create a the list exactly like this:[u'Citt\xe0', u'Hello', u'Publicit\xe0'] without double quotation and double \\? – CosimoCD Nov 25 '16 at 14:06