[Tutor] converting unicode
Terry Carroll
carroll at tjc.com
Wed Dec 1 04:05:33 CET 2004
On Tue, 30 Nov 2004, Rene Bourgoin wrote:
> Wandering how i could convert an entire tuple of unicode strings to python strings using str(u'string')
>
> stringtuple = ()
> stringtuple = (u'string1',u'string2',u'string3')
>
> str(u stringtuple) # syntax problem here!!!
>>> stringtuple = (u'a', u'bcd', u'e')
>>> ''.join(stringtuple)
u'abcde'
Interestingly, this is one area where string.join() gets a different
result:
>>> from string import join
>>> stringtuple = (u'a', u'bcd', u'e')
>>> join(stringtuple)
u'a bcd e'
I'm not sure why that would be.
More information about the Tutor
mailing list