Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. count = 0
  4. counttimes = 0
  5. while counttimes < 3 : # 输入错误信息3次就锁定(终止循环)
  6. user = input('Please input your name: ')
  7. pwd = input('Please input your password: ')
  8. if user == 'liuchao' and pwd == '123456':
  9. print ('welcome to beijing')
  10. break #输入正确的用户名和密码显示欢迎信息并结束
  11. counttimes +=1 #counttimes = counttimes + 1 (输入错误时计数加1)
  12. else :
  13. counttimes +=1 #counttimes = counttimes + 1 (输入错误时计数加1)
  14. if count < 2 : #第三次输入错误后打印锁定提示不再显示再出输入
  15. count += 1
  16. print ('please enter again')
  17. else :
  18. print ('You are not allowed to enter !!!') #锁定提示
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement