count = 0
flag = 1
lock = []
user_pass = []
username = input('Boy,你的名字:')
f = open('blacklist',mode='r')#读取黑名单的内容
lock_file = f.readlines()
f.close()
for i in lock_file:
line = i.strip('\n')
lock.append(line)
if username in lock:
print('Boy,你账户已经被锁定了!')#若输入的用户名在黑名单中,提示用户已经被锁定
else:
while True:
count += 1
passwd = input("Boy,你的密码:")
f = open('Users',mode='r')
user_file = f.readlines()
f.close()
for i in user_file:
user_pass = i.strip().split()
if username == user_pass[0] and passwd == user_pass[1]:
print('Welcome,Boy:' ,username)
flag = True
break
else:
continue
if flag is True:
break
else:
if count == 3:
print('Boy,你已经输错三次密码了,拉黑!')
lock_file = open('Blacklist',mode='a')
lock_file.write(username)
lock_file.close()
break
Users的账户:
alex 0714
egon 123123
gao 369521
Blacklist的拉黑账户:
qwe