首页 > 代码库 > python 小数相加报错 invalid literal for int() with base 10

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

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