码迷,mamicode.com
首页 > 其他好文 > 详细

登陆界面实现输错3次锁定

时间:2017-10-20 15:59:07      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:object   userdata   you   调用   welcome   data   value   输出   username   

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次锁定

标签:object   userdata   you   调用   welcome   data   value   输出   username   

原文地址:http://www.cnblogs.com/ols888/p/7699577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!