在python中将字符串列表转换为十进制列表为10个小数点

时间:2015-10-10 08:57:08

标签: python-3.x

如何转换下列列表:

['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

1 个答案:

答案 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]