登陆界面实现输错3次锁定
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了登陆界面实现输错3次锁定相关的知识,希望对你有一定的参考价值。
file_object = open(‘userdata.txt‘)
userdatadic = { }
log=0
erroruesr={}
def login():
for line in file_object:
line = line.strip(‘\n‘)
userdatalist =line.split(‘---‘)
userdatadic[userdatalist[0]] = userdatalist[1]
#从数据库中调用信息
for i in range(3):
username=input("uesrname:")
FBItext = open(‘FBI.txt‘)
for line in FBItext:
line = line.strip(‘\n‘)
if line ==username:
print("you‘re lose too many mistakes")
return
#判断是否黑名单
else:
password=input("password:")
for value in userdatadic.keys():
if value==username:
if userdatadic[value]==password:
print("welcome")
log = 1
break
#对比账号密码
else:
for v in erroruesr.keys():
if v == username:
erroruesr[username] += 1
break
else:
erroruesr[username] = 1
#记录输出的信息
if log == 1:
break
else:
for v in erroruesr.values():
if v>=3:
f = open("FBI.txt", ‘a‘)
f.write(username+"\n")
f.close()
print("you‘re lose too many mistakes")
#对比输错信息,并保存
login()
以上是关于登陆界面实现输错3次锁定的主要内容,如果未能解决你的问题,请参考以下文章