Simple question to split
Tiefeng Wu
icebergwtf at yahoo.com.cn
Thu Nov 9 20:51:46 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?
>
> Thx,
> Matthias
Maybe like this:
>>> a = "1,2,3,4,5,6,7,3,4"
>>> l = [int(n) for n in a.split(',')]
>>> l
[1, 2, 3, 4, 5, 6, 7, 3, 4]
>>>
___________________________________________________________
雅虎免费邮箱-3.5G容量,20M附件
http://cn.mail.yahoo.com/
More information about the Python-list
mailing list