String to sequence
mattia
gervaz at gmail.com
Sat Mar 14 05:37:38 EDT 2009
Il Sat, 14 Mar 2009 10:24:38 +0100, Ulrich Eckhardt ha scritto:
> mattia wrote:
>> How can I convert the following string:
>>
>> 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC',
>> EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'
>>
>> into this sequence:
>>
>> ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',
>> EGC','SXF','BZR','BIQ','BLL','BHX','BLQ']
>
> import string
> string.split("a,b,c", ',')
>
> Now, I'm not 100% clear if this fits your above example because it's not
> clear what of the above is Python code and what is actual string
> content, but I hope this will get you started.
>
> cheers!
>
> Uli
Well, it was quite easy (although I'm new to python ;-)). I scrape a list
of flights by their code [A-Z]{3} and then I save them into a sequence.
Reading the documentation now I've got:
dests = dests.replace("'", "")
dests = dests.split(",")
and everything is OK
More information about the Python-list
mailing list