![](/img/trans.png)
[英]unsupported operand type(s) for ** or pow(): 'str' and 'int' error
[英]I am getting this error unsupported operand type(s) for ** or pow(): 'str' and 'int'
为什么我收到此错误我正在创建一个 bmi 计算器:
unsupported operand type(s) for ** or pow(): 'str' and 'int'
代码片段:
Height= input("Enter Height in meter")
Weight= input (" Enter Weight in Kg ")
Result = int(weight)/int(height**2)
Print(result)
input()
返回一个字符串,该字符串必须转换为数字。
所以喜欢
height= int(input("Enter Height in meter"))
weight= int(input (" Enter Weight in Kg "))
result = weight/(height**2)
print(result)
无论您在input()
中输入什么,都将转换为字符串。 您可以将高度转换为 integer int(height)**2
或简单地将输入转换为 integer 该实例int(input("Enter Height in meter"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.