Writing the Login interface
- Enter User name password
- Show welcome message after successful authentication
- Three-time error after locking
1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 #author:orange 2018-01-24 Python 3.x4 #Login interface: Enter the user name password, after successful authentication display welcome information, the wrong 3 times after the lock. -----Multi-user password not resolved
5 6 ImportGetpass7_username ="Orange"8_password ="abc123"9Account_list = ["Orange"]TenLock_list = [] OneCount =0 A - whileTrue: -Input_username = input ("Username:") the - #determine whether the currently entered account is in the account list - ifInput_usernameinchaccount_list: - + #determine whether the currently entered account is in the Locked account list, and if so, prompt and exit. - ifInput_usernameinchlock_list: + Print("%s account is locked!"%input_username) A Break at Else: - #if the account password matches, display the login welcome information. -Input_password = Getpass.getpass ("Password:") - if_username = = Input_username and_password = =Input_password: - Print("Welcome User {name} login ...". Format (name=_username)) - Break in - #If the account password does not match, then prompts the error and the warning, the counter launches, enters 3 times the error to add the account number to the lock list. to Else: + Print("wrong password!") -Count + = 1 the Print("You enter the wrong password%s times!"%count) * Print("If You enter the wrong password 3 times, account would be lock!") $ ifCount = = 3:Panax Notoginseng lock_list.append (input_username) - the #The account is not in the list and the account is not indicated + Else: A Print("No {_name} account!". Format (_name = input_username))
Login Interface---Python