Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert list to unicode list

I have following list example

['Justice league', 'Avenger']

Now the problem i facing to convert list to unicode list
Unicode list example is

[u'Justice league', u'Avenger']

How can I achieve this? thank you for your response.

like image 644
Abdul Razak Avatar asked Feb 08 '23 22:02

Abdul Razak


1 Answers

try applying unicode to its elements

>>> lst=['Justice league', 'Avenger']
>>> map(unicode,lst)
[u'Justice league', u'Avenger']

Obviously we are talking about Python 2 only, since literal strings are unicode by default in Python 3

Have a look at this Q&A on the same subject

like image 97
Pynchia Avatar answered Feb 13 '23 04:02

Pynchia