【发布时间】:2021-10-20 18:55:27
【问题描述】:
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
当我运行它时...
What is your name?
>>> bn
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
bn
NameError: name 'bn' is not defined
版本
>>> import sys; print(sys.version)
3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
【问题讨论】:
-
只搜索错误信息“[python] NameError: name 'bn' is not defined”。恐怕从您提供的内容来看,该错误是不可重现的。作为这里的新用户,也请带上tour并阅读How to Ask。
-
什么意思?你真的不应该使用 Python2 并且你的代码在 Python3 中运行良好
-
@MicTest 请将所有代码和回溯放在问题本身中,以便其格式正确。
-
这看起来像是 Py2 与 Py3 的区别。如果您希望它在 Py2 下工作,请尝试“raw_input”而不是“input”。但是你不应该再使用 Py2...
-
如何,究竟你在运行这个?
标签: python python-3.x python-idle