擅长:python、mysql、java
<p>您不是在使用python 3,因此即时输入必须使用原始输入,因此这非常有效:</p>
<pre><code>heigth = float(input("Enter the height of the person: "))
sex = raw_input("Enter the person's gender:")
if(sex == "male"):
pi = (72.7 * heigth) - 58
elif(sex=="female"):
pi = (62.1 * heigth) - 44.7
else:
print("Invalid gender")
print("The ideal weight for this person is:",pi)
</code></pre>
<p>如果您的机器上有python3,我建议您使用:#!/usr/bin/python3,然后代码和你的一样</p>