String to sequence
Jeremiah Dodds
jeremiah.dodds at gmail.com
Tue Mar 17 06:17:01 EDT 2009
On Sat, Mar 14, 2009 at 9:09 AM, mattia <gervaz at gmail.com> 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']
>
> Thanks a lot,
> Mattia
> --
> http://mail.python.org/mailman/listinfo/python-list
>
I don't know if I'm missing something or what in other peoples replies (they
seem unnecessarily complicated) or if what popped into my head would be a
bad idea, but I would do:
>>> s = "'AAR','ABZ','AGA','AHO','ALC','LEI','AOC',
'EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'"
>>> s.replace("'","").split(',')
['AAR',
'ABZ',
'AGA',
'AHO',
'ALC',
'LEI',
'AOC',
'EGC',
'SXF',
'BZR',
'BIQ',
'BLL',
'BHX',
'BLQ']
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090317/db7ef37a/attachment-0001.html>
More information about the Python-list
mailing list