# -*- coding:utf-8 -*-
#需求模拟用户登录,超过三次错误锁定不允许登陆
 
 

count = 0

 
#realname passwd

Real_Username = "test"


Real_Password = "test"

 
#读取黑名单的内容

f = open('black_user','r')


lock_file = f.read()

f.close()
 

Username = input('请输入用户名:')

 
#判断输入用户是否在黑名单内,如果在则不允许输入密码

for i in range(1):


if lock_file == Username:


print('对不起,您的用户已锁定,暂时不允许使用!')


exit()


else:


continue

 
#尝试输入密码并对输入次数进行计数

for i in range(3):


Password = input("请输入密码:")


if Username == Real_Username and Password == Real_Password:


print("登录成功")


break


else:


print("登录失败")


count += 1

 
#如果输入三次错误密码,则提示用户名锁定,并将用户名拉黑

if count == 3:


print("对不起,您输入的密码错误次数已经达到3次,您的用户名将被锁定")


f = open("black_user","w")


f.write("%s"%Username)


f.close()