日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python错误修复_如何修复python错误(对象不可调用)

發布時間:2023/12/19 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python错误修复_如何修复python错误(对象不可调用) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

所以我現在正在學習Python,我編寫了以下代碼來練習: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循環再次開始并且我輸入了一個權重和高度之后,這段代碼似乎返回了一個錯誤。它第一次運行良好,但在我告訴它繼續運行,然后輸入重量和高度后,它崩潰并給出以下錯誤:

^{pr2}$

我想我應該在這里尋求幫助,因為我無法解決問題。

謝謝!在

總結

以上是生活随笔為你收集整理的python错误修复_如何修复python错误(对象不可调用)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。