On Sat, Mar 14, 2009 at 9:09 AM, mattia <ger...@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']
-- http://mail.python.org/mailman/listinfo/python-list