图片中老是出现这个问题,我将中间的变量改了之后,就可可以用了这是为什么?
#password.py
pwd =input('What is your password?')
if pwd == 12345: #note use of == instead of =
print('Loging on....')
else:
print('Incorrect password')
print('All done')
如果我将“pwd == 12345”改成了“pwd == ‘apple’”之后就会出现下面的问题
Traceback (most recent call last):
File "C:/python/password.py", line 2, in <module>
pwd =input('What is your password?')
File "<string>", line 1, in <module>
NameError: name 'apple' is not defined
这是什么原因,是需要我自己设置一个文件来定义name中有哪些名字吗?还是与版本有关?我用的版本是Python2.7.9
问题已经解决了