用戶登陸接口,輸錯3次限制登陸
阿新 • • 發佈:2018-06-26
pass tin In 用戶名 == lse odin user_list use
# _*_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
用戶登陸接口,輸錯3次限制登陸