Simple question to split
robert.kern at gmail.com
Thu Nov 9 23:59:12 CET 2006
Matthias Winterland wrote:
> 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()
"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