这是我借鉴别人的登录界面代码,为什么运行不了啊
#!/usr/bin/python
while True:
user = raw_input('Please input username:')
if user == ('Kate'):
password = raw_input('Please input password:')
while True:
if password != ('123'):
print "Wrong password,please try again!"
password = raw_input('Please input password:' )
if password == ('456'):
print "Hello %s,welcome to the system!" % user
break
break
else:
print "The username %s has not been found!" % user
你的代码内容没有问题,八成是代码结构问题:
我给你调了一下,起码不会报错了:
#!/usr/bin/python
while True:
user = raw_input('Please input username:')
if user == ('Kate'):
password = raw_input('Please input password:')
while True:
if password != ('123'):
print "Wrong password,please try again!"
password = raw_input('Please input password1:' )
if password == ('456'):
print "Hello %s,welcome to the system!" % user
break
break
else:
print "The username %s has not been found!" % user