首页 > 代码库 > python 小程序,输错三次密码锁定账户

python 小程序,输错三次密码锁定账户

技术分享

 1 [root@sun ~]# cat 7.py  2 #!/usr/bin/python 3 # -*- coding=UTF-8 -*- 4  5 usera_name   = usera 6 usera_passwd = aresu 7 usera_status = on 8 userb_name   = userb 9 userb_passwd = bresu10 userb_status = on11 ng = 012 13 14 name = raw_input(请输入用户名:)15 16 while ng < 3:17   if name == usera_name:18     passwd = raw_input(请输入密码  :)19     if passwd == usera_passwd:20       print 欢迎回来 usera !!!21       break22     else:23       ng += 124       if ng == 3:25         print 密码输入错误三次,账号已锁定 !!!26         usera_status = off27         break28   elif name == userb_name:29     passwd = raw_input(请输入密码  :)30     if passwd == userb_passwd:31       print 欢迎回来 userb !!!32       break33     else:34       ng += 135       if ng == 3:36         print 密码输入错误三次,账号已锁定 !!!37         usera_status = off38         break39   else:40     print 用户不存在,请重新执行41     break42 43 print usera_name,usera_status44 print userb_name,userb_status45 46 [root@sun ~]# python 7.py 47 请输入用户名:usera48 请输入密码  :149 请输入密码  :250 请输入密码  :351 密码输入错误三次,账号已锁定 !!!52 usera off53 userb on54 [root@sun ~]# python 7.py 55 请输入用户名:userb56 请输入密码  :357 请输入密码  :258 请输入密码  :159 密码输入错误三次,账号已锁定 !!!60 usera off61 userb on62 [root@sun ~]# python 7.py 63 请输入用户名:sun64 用户不存在,请重新执行65 usera on66 userb on67 [root@sun ~]# python 7.py 68 请输入用户名:usera69 请输入密码  :aresu70 欢迎回来 usera !!!71 usera on72 userb on

 

python 小程序,输错三次密码锁定账户