标签:article cccccc txt ati open 被锁 address form pre
lock={}
flag = True
with open("username.txt",encoding="utf8") as f_user,open("locked.txt",mode="a+",encoding="utf8") as f_lock :
while flag:
user_name = input("请输入你的帐号:")
passwd = input("请输入你的密码:")
f_lock.seek(0)
f_user.seek(0)
for user_lock in f_lock:
if user_lock.strip() == user_name :
print ("此帐号已被锁定!")
break
for user in f_user:
user_f,passwd_f = user.strip().split("----")
if user_f == user_name :
if passwd_f == passwd:
print("欢迎回来,"+user_name)
flag = False
break
else:
if user_name in lock:
lock[user_name] +=1
else:
lock[user_name]=1
print("帐号或密码错误!")
break
if user_name in lock and lock[user_name] >= 3:
print("帐号锁定!")
f_lock.write(user_name+‘\n‘)
lock.pop(user_name)
flag = False
break
print("----继续----")
标签:article cccccc txt ati open 被锁 address form pre
原文地址:http://www.cnblogs.com/kimyeee/p/6687140.html