Demand:
- Can support multiple users login (prompt, through the list to save multiple account information)
- After the user 3 authentication failed, quit the program, start the program again when attempting to log on, or lock the status (hint: the user locked state must be stored in the file)
Flow chart:
Code:
1div={2 'List1':{'Password':'123456'},3 'List2':{'Password':'123456'},4 'List3':{'Password':'123456'},5 }6f = open ('Black_user','R')7Lock_file =F.readlines ()8 f.close ()9Count=0Tencount1=0 One whileTrue: AName_input=input ("Please input name:") - ifCount = = 3: - Print("user name input number reached limit") the Break - if notName_inputinchDiv: - Print("User name Error") -Count +=1 + ifName_inputinchLock_file: - Print("the user name is locked and paused! ") + exit () A at ifName_inputinchDiv: -Count-=2 -PASSWORD_INPUT=STR (Input ("Please input password:")) - ifPassword_input = = div[name_input]['Password']: - Print("Password Successful") - Break in Else: - Print("Password Error") toCount1 +=1 + ifCount1 = = 2: - Print("you have entered the wrong number of passwords 3 times, will lock your account!") thef = open ('Black_user','W') *F.write ('%s'%name_input) $ f.close ()Panax Notoginseng Break
Python Multi-User Login