Simple question to split
faulkner
faulkner612 at comcast.net
Thu Nov 9 18:02:00 EST 2006
def splits(seq, cs):
if not cs: return seq
elif isinstance(seq, str): return splits(seq.split(cs[0]), cs[1:])
else: return splits(sum([elem.split(cs[0]) for elem in seq], []),
cs[1:])
or
a = re.split('(\ |\,)', a)
a.remove(' ')
a.remove(',')
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?
>
> Thx,
> Matthias
More information about the Python-list
mailing list