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