Python 为什么我的程序说里根没有定义,即使我用双引号引用了这个名字,我的意思是';这不是一个变量吗?
更新 这是从终端运行时程序的输出:Python 为什么我的程序说里根没有定义,即使我用双引号引用了这个名字,我的意思是';这不是一个变量吗?,python,Python,更新 这是从终端运行时程序的输出: print ("This is a simple login") while True: enter = input("Enter the password for this computer: ") if enter == "Reagan": time.sleep(1) print ("Your Login is successful") else: print ("Password d
print ("This is a simple login")
while True:
enter = input("Enter the password for this computer: ")
if enter == "Reagan":
time.sleep(1)
print ("Your Login is successful")
else:
print ("Password didn't match! ")
C:\Python27\python.exe“C:/python编程/Practice/for loops.py”
这是一个简单的登录
这台计算机的密码:Reagan
回溯(最近一次调用last):文件“C:/Python Programming/Practice/for loops.py”,
第3行,在enter=input(“输入此计算机的密码:”)文件“”中,
NameError中的第1行:未定义名称“Reagan”,进程已结束,退出代码为1
您需要原始输入()
Python 2?使用raw_input
notinput
您的代码错误,缺少缩进!!
C:\Python27\python.exe "C:/Python Programming/Practice/for loops.py"
This is a simple login Enter
the password for this computer: Reagan
Traceback (most recent call last): File "C:/Python Programming/Practice/for loops.py",
line 3, in <module> enter = input("Enter the password for this computer: ") File "<string>",
line 1, in <module> NameError: name 'Reagan' is not defined Process finished with exit code 1
import time
print ("This is a simple login")
while True:
enter = raw_input("Enter the password for this computer: ")
if enter == "Reagan":
time.sleep(1)
print ("Your Login is successful")
else:
print ("Password didn't match! ")