In short:
There's no need to convert you list of unicodes into strings. They're the same thing
In long:
The u'...'
prefix in the string object represents a Unicode object introduced in Python 2.0, see https://docs.python.org/2/tutorial/introduction.html#unicode-strings
Starting with Python 2.0 a new data type for storing text data is
available to the programmer: the Unicode object. It can be used to
store and manipulate Unicode data (see http://www.unicode.org/) and
integrates well with the existing string objects, providing
auto-conversions where necessary.
And since Python 3.0, see https://docs.python.org/3.2/tutorial/introduction.html#about-unicode:
Starting with Python 3.0 all strings support Unicode (see
http://www.unicode.org/).
Regardless of what is the default string type, when checking for equivalence, they should be the same in both Python 2.x and 3.x:
alvas@ubi:~$ python2
Python 2.7.11 (default, Dec 15 2015, 16:46:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type(u'man')
<type 'unicode'>
>>> type('man')
<type 'str'>
>>> u'man' == 'man'
True
alvas@ubi:~$ python3
Python 3.4.1 (default, Jun 4 2014, 11:27:44)
[GCC 4.8.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> type(u'man')
<class 'str'>
>>> type('man')
<class 'str'>
>>> u'man' == 'man'
True
And in Python 2, when you MUST or are required to convert from unicode
to str
type let's say for type checks or something, e.g.:
alvas@ubi:~$ python3
>>> u'man' == 'man'
True
>>> type(u'man') == type('man')
True
>>> exit()
alvas@ubi:~$ python2
>>> u'man' == 'man'
True
>>> type(u'man') == type('man')
False
then you should be able to simply cast it to str(u'man')
or u'man'.encode('utf-8')
.
But there could be some "pain" / endless errors if your unicode string is out of the ascii range and you're trying to write it to file or print it onto console which might not have defaultencoding set to 'utf-8'. In that case, watch https://www.youtube.com/watch?v=sgHbC6udIqc
Additionally, here are similar questions relating to the u'...'
prefix: