标签:检查 认证 input break 提示 use print 多个 用户登录
基本需求:
1 user_tab={ 2 ‘user01‘:{"pass":"123","count":0}, 3 ‘user02‘:{"pass":"123","count":0}, 4 ‘user03‘:{"pass":"123","count":0}, 5 } 6 while True: 7 username=input("please input your name: ") 8 if not username in user_tab: 9 print("用户不存在,请检查用户名,谢谢!") 10 continue 11 f = open(‘user.txt‘,‘r‘) 12 bb = f.read().splitlines() 13 if username in bb: 14 print(‘账户已经被锁定!请联系管理员!!!‘) 15 continue 16 17 password=input("please input your password: ") 18 19 if user_tab[username][‘count‘] > 2: 20 print(‘输入的密码错误次数太多了!账户已锁定!!!‘) 21 with open(‘user.txt‘,‘a+‘) as f: 22 f.write(username) 23 f.write(‘\n‘) 24 break 25 if password == user_tab[username][‘pass‘]: 26 print(‘欢迎登陆系统‘,username) 27 break 28 else: 29 print("密码错误,请重试!") 30 user_tab[username][‘count‘]+=1 31 continue
标签:检查 认证 input break 提示 use print 多个 用户登录
原文地址:http://www.cnblogs.com/yxwang/p/7131210.html