dic={'egon1':'123','egon2':'123','egon3':'123'}
tag=True
while True:
name=input('输入用户名:')
if name not in dic:
print('用户名不存在')
continue
else:
with open('db.txt','r') as p:
lock_uesers=p.read().split('|')
if name in lock_uesers:
print('用户%s已经被锁定,'%name)
continue
else:
x=0
while tag:
sky = input('输入密码:')
if x==2:
print('用户锁定')
with open('db.txt','a') as p:
p.write('%s|'%name)
break
if sky == dic[name]:
print('登陆成功!')
break
else:
print('密码错误,请重新输入')
x+=1