python解决:invalid literal for int() with base 10

    print(int("1.1"))
ValueError: invalid literal for int() with base 10: '1.1'

确定报错原因为参数有误,int()函数可以把数字字符串转化成int类型的数字,但是不能传入非数字的字符串

更改为:print(int(float("1.1")))

for i in range(3):
age=int(round(float(input('请输入年龄:'))))
if age >= 18:
print('成年人')
else:
print('小朋友')
i +=1
posted @ 2022-02-07 14:13  liulj0713  阅读(1331)  评论(0)    收藏  举报