如何转换下列列表:
['524.7940719572', '0.1874483617', '0.0321140582', '228.8002278843', '6843.5984811891', '29.9108027316', '60.2048797607', '220.7372120052', '556.828334181']
为:
[524.7940719572, 0.1874483617, 0.0321140582, 228.8002278843, 6843.5984811891, 29.9108027316, 60.2048797607, 220.7372120052, 556.828334181] in python
答案 0 :(得分:1)
l = ['524.7940719572', '0.1874483617', '0.0321140582', '228.8002278843', '6843.5984811891', '29.9108027316', '60.2048797607', '220.7372120052', '556.828334181']
i = 0
for v in l:
l[i] = float(v)
i = i+1
print l
得出以下结果:
[524.7940719572, 0.1874483617, 0.0321140582, 228.8002278843, 6843.5984811891, 29.9108027316, 60.2048797607, 220.7372120052, 556.828334181]