[Tutor] Converting from unicode to nonstring
Sander Sweers
sander.sweers at gmail.com
Thu Oct 14 20:19:57 CEST 2010
On 14 October 2010 16:14, David Hutto <smokefloat at gmail.com> wrote:
> (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10')
>
> Which is a tuple of unicode strings. From this I
> need to place portions of the tuple into other fields,
> but not as unicode strings, but literals no ''.
>
> For example if I have the following line:
>
> self.lines = self.newplot.plot([1,2,3,4])
So you want convert string u'1,2,3,4' to a list of ints [1,2,3,4]?
Then the below will work.
[int(n) for n in u'1,2,3,4'.replace(',', '')]
Greets
Sander
More information about the Tutor
mailing list