1 #!/user/bin/env python2 #-*-coding:utf-8-*-3 __author__='Howie'4 " "5 Job Requirements:6 1. Enter the user password7 2. Show welcome information after authentication8 3. Three times after the wrong lock9 " "Ten ############################## One " " A Readme: - This is a login interface script that requires the correct user name and password to be entered, and will be locked if the input fails three times. - now there is a bug that three input errors will only be the first time the user name to lock. the " " -Account_file ='User.txt' -Lock_file ='Account_lock.txt' -Userpass ='F' +Count =0 - whileUserpass = ='F' andCount <3: +Username = input ('Enter user name:') APassword = input ('Enter Password:') atCount +=1 -With open (Lock_file,'R') as F:#Open the Locked users list - forLineinchF.readlines ():#Traverse each line of the document -Username = Line.strip ()#The string of each row is separated by a space and assigned a value - ifUsername = = Username:#determine if the user is in the lock table - Print('your account is locked') inUserpass ='L' - Break to ifUserpass = ='L':#jump out of white loop when marked L + Break -With open (Account_file,'R') as F:#Open User List the forLineinchF.readlines ():#Traverse each line of the document *Username,password = Line.strip (). Split ()#The string of each row is separated by a space and assigned a value $ ifUsername = = Username andPassword = = Password:#determine the user name and password are correctPanax Notoginseng Print('Successful Landing') -Userpass ='T' the Break #after a successful check mark is T and jump out of the current loop to the while judgment Mark T and then jump out of all loops + ifCount >=3 andUserpass = ='F':#accurate judgment times and markings A Print("excessive number of errors, the account is locked") theWith open (Lock_file,'A +') as L: +L.write ('\ n') -L.write (Username)Login Interface Code
This is the first time I've written so many codes in Python.
It's very poorly written.
I think the most important thing is to be clear about the hierarchical relationship of the cycle.
2017python First day Homework