Python login interface (1) and python login interface
Job: contains the following content: zhangbin 123zhb 456 jack 122lock file account_lock.txt is empty by default # coding: gbk # author: zhbimport getpass, OS, sysos. system ('cls') I = 0 while I <3: name = raw_input ('input Username: ') lock_file1_open(r'account_lock.txt', 'r + ') for lock_line in lock_file.readlines (): lock_line = lock_line.strip ('\ n') if lock_line = name: sys. exit ('USER % s exists in the locked file! Log on to the O & M platform again! Goodbye! '% Name) else: pass user_file1_open(r'account.txt', 'R') for user_line in user_file.readlines (): (user, password) = user_line.strip ('\ n '). split () if user = name: j = 0 while j <3: passwd = getpass. getpass ("input password:") if password = passwd: sys. exit ("warmly welcome % s to the O & M platform" % name) else: if j! = 2: print ("Incorrect password, USER % s still has % d chance to enter" % (name, 2-j) j + = 1 else: when the primary key is lost 3 times, the lock_file.write (name + '\ n') sys is locked and added to account_lock.txt. exit ("this account % s has been locked due to three consecutive password input errors. Please contact IT staff to unbind" % name) else: pass I + = 1 else: sys. exit ('user % s does not exist in the system. Please log on again '% name)