python错误修复_如何修复python错误(对象不可调用)
所以我現(xiàn)在正在學(xué)習(xí)Python,我編寫了以下代碼來練習(xí):import time
from decimal import Decimal
name = input("\nPlease enter your name: ")
def bmi(weight, height):
bmi = weight/(height**2)
if bmi > 29.9:
report = "obese"
elif bmi <= 29.9 and bmi > 24.9:
report = "overweight"
elif bmi <= 24.9 and bmi > 18.5:
report = "normal"
elif bmi <= 18.5:
report = "underweight"
else:
report = "to be lying"
return (bmi, report)
while True:
weight = Decimal(input("\nEnter your weight (kg): "))
if weight == 0:
print("You can't have a weight of 0. Try again!")
continue
if weight < 0:
print("A negative weight? Really?")
continue
height = Decimal(input("Enter your height (cm): "))
height = height/100
bmi, report = bmi(weight, height)
bmi = round(bmi, 1)
time.sleep(1)
print("\n" + name.title() + ", according to your BMI (" + str(bmi) +
"), you are considered " + report + ".")
qprompt = input("\nDo you wish to quit? (y/n): ")
if qprompt == 'y':
break
else:
continue
在while循環(huán)再次開始并且我輸入了一個權(quán)重和高度之后,這段代碼似乎返回了一個錯誤。它第一次運行良好,但在我告訴它繼續(xù)運行,然后輸入重量和高度后,它崩潰并給出以下錯誤:
^{pr2}$
我想我應(yīng)該在這里尋求幫助,因為我無法解決問題。
謝謝!在
總結(jié)
以上是生活随笔為你收集整理的python错误修复_如何修复python错误(对象不可调用)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dnf元素怎样进行加点(地下城与勇士)
- 下一篇: websocket python爬虫_p