多个 密码错误 section comm 成功 管理员 += lease
基本需求:
- 1user_tab={
- 2 'user01':{"pass":"123","count":0},
- 3 'user02':{"pass":"123","count":0},
- 4 'user03':{"pass":"123","count":0},
- 5 }
- 6 while True:
- 7username=input("please input your name: ")
- 8 if notusernamein user_tab:
- 9 print("用户不存在,请检查用户名,谢谢!")
- 10 continue
- 11f = open('user.txt','r')
- 12bb = f.read().splitlines()
- 13 ifusernamein bb:
- 14 print('账户已经被锁定!请联系管理员!!!')
- 15 continue
- 16
- 17password=input("please input your password: ")
- 18
- 19 ifuser_tab[username]['count'] > 2:
- 20 print('输入的密码错误次数太多了!账户已锁定!!!')
- 21with open('user.txt','a+') as f:
- 22 f.write(username)
- 23f.write('\n')
- 24 break
- 25 ifpassword == user_tab[username]['pass']:
- 26 print('欢迎登陆系统',username)
- 27 break
- 28 else:
- 29 print("密码错误,请重试!")
- 30user_tab[username]['count']+=131 continue
python 多用户认证
来源: http://www.bubuko.com/infodetail-2157320.html