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?

1
  • 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. Commented Nov 26, 2016 at 3:53

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.