Local Log File simulation
user.txt text file data format:
username:password
. 1 # Coding: UTF. 8- 2 . 3 # read data . 4 userfile = Open ( " user.txt " , " R & lt " ) . 5 userList = userFile.readlines () . 6 . 7 # logins limit . 8 COUNT =. 3 . 9 10 # log success mark 11 Flag = True 12 13 the while COUNT> 0 and Flag: 14 # to enter a user name and password 15 the user = the iNPUT ( " the enter the user your name: " ) 16 password = INPUT ( " the Enter your password: " ) . 17 18 is # Log decremented. 1 . 19 Count -. 1 = 20 is 21 is # cycle validation 22 is for Line in userList: 23 is 24 # removed at the end of the text file and split carriage return line is a partial list of account password 25 user1 = line.strip ( " \ n- " ) .split ( " : " ) 26 is 27 # for account password verification 28 IF User == user1 [0] and password == user1 [. 1 ] : 29 # Verification is successful update of the mark and the loop ends 30 In Flag = False 31 is BREAK 32 the else : 33 is # In Flag is True then the account password authentication fails, count = 3 while the lead end of the loop 34 is IF In Flag: 35 Print ( " logins has reached three times, login failures, account lockout " ) 36 the else : 37 Print ( " Login successful " ) 38 39 # turn off data 40 userFile.close ()