Discuss / Python / 运行不了,有大神可以帮我一下吗?

运行不了,有大神可以帮我一下吗?

Topic source
# -*- coding: utf-8 -*-

height = 1.75
weight = 80.5

bmi = weight/height**2

if bmi<18.5:

    print(体重过轻)

elif bmi<25:

    print(体重正常)

elif bmi<28:

    print(体重过重)

elif bmi<32:

    print(肥胖)

else:

   print(严重肥胖)

Traceback (most recent call last):

  File "main.py", line 11, in <module>

    print(体重过重)

NameError: name '体重过重' is not defined

哪里出现了问题呢?我想print一个字符串,为什么出现了错误呢?

comingforth

#2 Created at ... [Delete] [Delete and Lock User]

print("体重过重")

要加上双引号,不然会被认为是个变量/常量之类的


  • 1

Reply