Simple question to split
Robert Kern
robert.kern at gmail.com
Thu Nov 9 17:59:12 EST 2006
Matthias Winterland wrote:
> 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?
You can't get what you want with a single method call. You can do it with a
single call to .split() if you preprocess the string first:
a.replace(',', ' ').split()
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list