Simple question to split

Georg Brandl g.brandl-nospam at gmx.net
Thu Nov 9 17:57:51 EST 2006


Diez B. Roggisch schrieb:
> Diez B. Roggisch schrieb:
>> Matthias Winterland schrieb:
>>> Hi,
>>>
>>> I have a simple question. When I read in a string like:
>>> a='1,2,3,4,5 6 7,3,4', can I get the list l=[1,2,3,4,5,6,7,3,4] with a 
>>> single split-call?
>> 
>> Nope. But you could replace the commas with spaces, and then split.
> 
> Or use re.split....

And not forget to map it through int() afterwards.

Georg



More information about the Python-list mailing list