''' 编写登陆接口 •输入用户名密码 •认证成功后显示欢迎信息 •输错三次后锁定 •并且用户名被就在restrictuser.txt下面,如果想解除锁定就要到文本下面删除user ''' countnumber=0 while countnumber <3: ###输入三次错误后锁定 # for i in open (r"D:Pythonuserpasswd.txt").readlines(): username = input("Please input the username:") password = input("Please input the passwd:") f1 = open(r'D:Python estrictuser.txt').read() rest=f1.count(username) print(rest) if rest >= 3: print("Your ID have been locked,Please contact the administrator") exit() i = open(r"D:Pythonuserpasswd.txt").read() # print(i.split(" ")[1].strip()) # print(type(i.split(" ")[0])) # break if username == i.split(" ")[0].strip() and password == i.split(" ")[1].strip(): print ("Welcome Login") exit() else: print("You have %s chance"%(2-countnumber)) countnumber+=1 f = open(r'D:Python estrictuser.txt','a') f.writelines(' ' + username ) f.close() continue else: print("Your ID have been locked") exit() #a = f.readline() #print (f) #错误信息 #SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 9-10: truncated uXXXX escape #print (username,password)