用户登陆接口,输错3次限制登陆

# _*_coding:utf-8_*_
# Author:len liu

'''
让用户输入用户名密码
认证成功后显示欢迎信息
输错三次后退出程序
'''

user_list = {
"len":'aaa',
"alen":'bbb',
"blen":'ccc'
}
count = 0
while True:
user_input = input("pls input username:")
passwd_input = input("pls input password:")

if user_input not in user_list:
print("no this user")
continue
with open('black_list.txt','r') as f:
lock_user=f.read().split(',')
#print(lock_user)
if user_input in lock_user:
print('your count %s locked!'%user_input)
break

if user_input in user_list and passwd_input == user_list[user_input]:
print("login sucessful!")
break
else:
print("invaild username or password")
count +=1
if count >2 :
with open('black_list.txt','a') as f:
f.write(user_input +',')
print("your count try too times ,locked!")
break





猜你喜欢

转载自www.cnblogs.com/len1028/p/9228299.html
今日推荐