python 小数相加报错 invalid literal for int() with base 10

for i in column1:
x = int(i)
s += x
print "sum:",s,"count:",len(column1)
# round (s / len(column1), 3)
print "avg",round (s / len(column1), 3)


Traceback (most recent call last):
File "C:/3/csv测试.py", line 26, in <module>
x = int(i)
ValueError: invalid literal for int() with base 10: '18.4'

 

这里的错误在于用了int 应该用float

posted on 2017-05-25 22:47  寒星12345678999  阅读(726)  评论(0编辑  收藏  举报