#Locklist.txt Impersonation Lock user list format is as follows#User1#User2#userlist.txt Template Registration user list format is as follows#User1:password1#User2:password2#number of inputs initializedCount =0 whileTrue:#Get user InputUsername = input ("Input your username:") Password= Input ("Password:") #determine whether the user is locked in the user listlock_list = open ("Locklist.txt","R") whileTrue:lock_list_line= Lock_list.readline (). Split (":") ifUsername = = Lock_list_line[0].replace ("\ n",""): Print("User is locked") exit ()elifLock_list_line[0] = ="": Breaklock_list.close ()#determine if the user's password is correctuser_list = open ("Userlist.txt","R") whileTrue:user_list_line=user_list.readline (). Split (":") ifUsername = = User_list_line[0] andPassword = = User_list_line[1].replace ("\ n",""): Print("welcom"+username) exit ()elifUsername = =User_list_line[0]: Count+=1#same user password error three times write user to lock list ifCount = = 3: Lock_list= Open ("Locklist.txt","a") Lock_list.write (username+"\ n") Lock_list.close () exit ("User is locked") Print("Password input Error! ") Break elifUser_list_line[0] = ="": Print("user does not exist! ") Breakuser_list.close ()
Python3 impersonate a user password three times after the error is locked