错误001 --can't multiply sequence by non-int of type 'float'

代码:

 weight = input("请输入您的体重:")
 print(12.1*weight)

input输入的是字符串,不能用字符串乘以浮点数,改为:

weight = eval(input("请输入您的体重:"))
print(12.1*weight)


 

猜你喜欢

转载自blog.csdn.net/shmily_syw/article/details/92101766