0
因此,我正在学习python,从Java背景,为我的新工作,我遇到了以下错误。基本的Python模块错误
我试着在终端上(使用mac)运行这个模块,然后通过空闲。都是徒劳的。
userName = input("What is your name?: ")
lengthName = str(len(usernName))
yourName = "\nYour name is " + userName + " and is " + legnthName + " letters long."
print(yourName)
input("\nPress enter to exit")
当此在终端被执行,I型为第一输入: “约翰” 我得到这个结果:
File "[...]", line 1, in <module>
userName = input("What is your name?: ")
File "<string>", line 1, in <module>
NameError: name 'John' is not defined
类似地,当经由IDLE执行:
Traceback (most recent call last):
File "/Users/zachmartin/Desktop/python fails/lol.py", line 2, in <module>
lengthName = str(len(usernName))
NameError: name 'usernName' is not defined
这是怎么回事?
果然,谢谢! – MITjanitor 2013-03-27 19:02:07