笔者QQ: 360212316
逻辑图
代码
#/usr/bin/python
# -*- coding: utf-8 -*- lock = open("black_user_list.txt", 'a', encoding='utf-8')
lock.write("\n")
user_list = open("userlist.txt", 'w+', encoding='utf-8')
user_list.write("zhangsan\n")
user_list.write("lisi\n")
user_list.close()
user_list = open("userlist.txt", 'r', encoding='utf-8')
white_username = user_list.read().strip()
user_list.close()
lock = open("black_user_list.txt", 'r+', encoding='utf-8')
lock_username = lock.read().strip()
while True:
username = input("username:")
if username in lock_username:
print("\033[31;1m %s Account lockout \033[0m" % username)
break
elif username in white_username:
for i in range(2, -1, -1):
password = input("password:")
if password == 'abc123':
print("Welcome to log on %s" % username)
break
else:
print("\033[31;1mPassword remaining: \033[0m %s" % i)
if i == 0:
print("\033[31;1m %s Account lockout \033[0m" % username)
lock.write("\n")
lock.write(username)
lock.close()
exit()
else:
print("Account does not exist")