python设计登录程序
代码含义:输入用户,如果用户不符合,继续输入用户,直至输入正确的用户;
再接着输入密码,同样也是,直至密码输入对即可,最终登录到系统。
实现代码如下:
#!/usr/bin/python
while True:
name = raw_input("please input your name:")
if name == 'dingwei':
password = raw_input("please input your password:")
while password != 'cbh':
password = raw_input("please input your password:")
print "----------------------------------"
print "welcome to login to system!"
break
else:
print "user %s not found,try again!" % name
效果截图:
页:
[1]