大家好,我在尝试对列表中的所有值求和时遇到问题。我不确定这是否真的可行。
dL= list(csv.reader(input))
sL = dL [14247:14611]
a = [row[5] for row in sL[1:]]
print a
这段代码是我到目前为止所拥有的并产生结果
['5.0', '0.0', '0.0', '0.0', '0.0', '1.6', '4.4', '14.0', '0.0', '0.0', '0.8', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '0.0', '0.0', '0.0', '95.6', '63.6', '0.0', '0.0', '0.0', '9.0', '0.0', '0.0', '0.0', '0.0', '20.2', '14.4', '1.6', '0.0', '7.6', '2.4', '0.0', '11.4', '0.0', '79.4', '60.4', '27.2', '', '1.8', '0.0', '0.0', '29.6', '67.6', '2.2', '0.0', '0.0', '0.0', '14.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '', '3.2', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '6.2', '0.0', '0.0', '0.0', '0.8', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '11.8', '2.4', '0.0', '0.0', '0.0', '0.4', '16.8', '8.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '2.6', '27.2', '77.0', '0.2', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '9.2', '2.6', '0.0', '0.2', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '0.0', '0.0', '0.0', '0.2', '0.0', '0.0', '0.0', '0.0', '1.6', '0.0', '0.0', '0.0', '0.0', '0.0', '6.8', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '', '', '', '', '', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '37.8', '0.2', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0', '0.0']
上面的列表不是输入的,而是由功能代码产生的。这会影响结果吗?
谁能帮助我向我展示如何解决此问题并将所有这些值汇总到此列表中的代码中。我相信我必须加入字符串才能这样做,但我不确定。您能否告诉我这是否可以将列表的所有这些值相加,如果可以,我该怎么做?
编辑:
THANKS FOR ALL THE HELP GUYS