求 解释下 这段 python 代码

wwwmmm 发布于 2012/07/18 14:00
阅读 313
收藏 0

小弟初学python 求详细解释下  下面这段代码 

line = "GOOD,100,490,10"
field_types = [str,int,float]
raw_fields = line.split(',')
fields = [ty(val) for ty,val in zip(field_types,raw_fields)]

加载中
0
永远对你好
永远对你好
十分简单。自己看书。
0
deleted
deleted
把"GOOD,100,490,10"切成"GOOD","100","490","10"的列表

用zip拼接成((str,"GOOD"),(int,"100"),(float,"490"))

迭代,执行str("GOOD"), int("100"), float("490") 形成一个新的list
0
wwwmmm
wwwmmm

引用来自“勇者天空”的答案

把"GOOD,100,490,10"切成"GOOD","100","490","10"的列表

用zip拼接成((str,"GOOD"),(int,"100"),(float,"490"))

迭代,执行str("GOOD"), int("100"), float("490") 形成一个新的list
ty()是什么意思呢 
0
deleted
deleted

引用来自“有生之年”的答案

引用来自“勇者天空”的答案

把"GOOD,100,490,10"切成"GOOD","100","490","10"的列表

用zip拼接成((str,"GOOD"),(int,"100"),(float,"490"))

迭代,执行str("GOOD"), int("100"), float("490") 形成一个新的list
ty()是什么意思呢 
只是一个变量名, ((str,"GOOD"),(int,"100"),(float,"490"))各项的第一个
0
wwwmmm
wwwmmm

引用来自“勇者天空”的答案

引用来自“有生之年”的答案

引用来自“勇者天空”的答案

把"GOOD,100,490,10"切成"GOOD","100","490","10"的列表

用zip拼接成((str,"GOOD"),(int,"100"),(float,"490"))

迭代,执行str("GOOD"), int("100"), float("490") 形成一个新的list
ty()是什么意思呢 
只是一个变量名, ((str,"GOOD"),(int,"100"),(float,"490"))各项的第一个
哦  懂了 谢了
0
jackliu8722
jackliu8722
看来是新手啊
返回顶部
顶部