1 #!/usr/bin/env python2 #_*_ coding:utf-8 _*_3 #Three login4 ImportSys,os5Os.system ('Clear')6Retry_limit = 37Retry_count =08Account_file ='Account.txt'9Lock_file ='Account_lock.txt'Ten One defLock (username): Af = open (Lock_file,'RB') - forLineinchf.readlines (): - ifUsername = = Line.strip ('\ n'): theSys.exit ('User%s is locked!!!'%username) - - - defLogin (Username,password): + GlobalRetry_count - whileRetry_count <Retry_limit: +f = open (Account_file,'RB') AMatch_flag =False at forLineinchf.readlines (): -USER,PASSWD = Line.strip ('\ n'). Split () - ifUsername = = User andPassword = =passwd: - Print('Hello,%s !!!'%username) -Match_flag =True - Break in f.close () - to ifMatch_flag = =False: + Print('Sorry,%s is error'%username) -Retry_count + = 1 the Else: * Print('Welcome Login%s!!!!'%username) $ BraekPanax Notoginseng Else: - Print("Your account, %s is locked!!!"%username) theg = Open (Lock_file,'a') + g.write (username) AG.write ('\ n') the g.close () + - $ defMain (username, password): $ Lock (username) - Login (Username,password) - the -Username = Raw_input ("Username:")WuyiPassword = raw_input ("Password") the Main (username, password) - Wu - About #def main (): $ #username = raw_input ("username:") - #Password = raw_input ("password") - #Lock (username) - #Login (Username,password) A #Main ()
Python 3-Time Login