登录失败三次锁定用户
被人逼迫果然是学习的最好动力,登录成功或全部账号都登陆失败三次被锁定后结束。希望几个月后我在看这段代码能觉得自己lowb,有所长进
count = 0
i = 0
state = {'admin':1,'张三':1,'王五':1}
namelist = {'admin':1111,'张三':2222,'王五':3333}
while i < 4 :
if i == 3 :
print('全部账号都已锁定,请联系管理员!')
break
elif i < 3:
username = input('请输入你的用户名:')
if username in state.keys() and state[username] == 2:
print('该用户被列入黑名单,请尝试登录其他用户!')
continue
elif username not in namelist.keys():
print('用户名错误,该用户未注册,请重试')
continue
else :
value = namelist[username]
while count < 3 :
passwd = input('请输入密码:')
if passwd == str(value):
print('登陆成功!')
print('欢迎登录%s!' % username)
i += 4
break
elif passwd != str(value) and count < 2 :
print('密码错误,请重新输入')
count += 1
else :
print('该账户登录失败三次,已被锁定,请使用其他账户登陆')
state[username] = 2
print(state)
count = 0
i += 1
break