# readme:# blogger Address:www.cnblogs.com/ne-zha# ne_zha# Requirements: # Write Login Interface #1. Enter user name password #2. Login successful display welcome message #3Error three lock Lock_file=open ('File_lock.txt','R') User_pass=open ('Username_file.txt','R') cmd=int(Input (" "Login System input 1 exit System input 2 Please enter the operation:" "))ifcmd = =2: Exit () elif cmd==1: Username= Input ("Please input your user ...") forIinchRange3): forIinchlock_file.readlines (): I=I.split ()ifUsernameinchi[0]: Print ('Sorry,%s is locked'%username) exit () match=False forJinchuser_pass.readlines (): user,passwd=J.split ()ifUsername = =User:password=input ("Please input the passwd") ifPassword = =Passwd:print ("Login Successful! ") Match=True Breakelif Password!=passwd: forNinchRange2): Password=input ("password error, please re-enter! ") ifPassword = =Passwd:print ("Login Successful! ") Match=True Break ifUsername! =User:print ("user name does not exist! ") exit ()ifMatch = =False:print ("three input errors, account to be locked! ") Lock_file.write ('%s \ n'%username) lock_file.close () User_pass.close () exit ()
Python diary, simple password login