#-*-Coding:utf-8-*-
#Author David
"""
Feature Description: Write the Login interface
Enter user name and password
Show welcome message after successful authentication
Three-time error after locking
"""
#用户信息表
user = "David"
passwd = "123456"
unlock = 1
Error_count = 0
"""
defining function bodies
Function Description:
1) When the user enters the user name, the first to determine whether the existence, if there is the next judgment, if not present, prompt for the user name.
2) When the user name exists, the system determines whether the user state is locked, if the lock indicates that the account is locked, if the account is unlocked, the user is prompted to enter the password.
3) If the password authentication is passed, the welcome interface is displayed and the error input is zeroed in.
4) If the password verification does not pass, accumulate the wrong number of entries and enter the next cycle.
5) If the accumulated 3 times the wrong password, then set the unlock to 0, the user account lock.
"""
def main ():
#输入用户名
While True:
Username = input ("Please input your username:")
If username = = User:
Global Error_count
Global unlock
If unlock:
Password = input ("Please input your password:")
if password = = passwd:
Print ("{0}, welcome for your back!". Format (username))
error_count= 0
Else
Error_count +=1
If Error_count > 2:
Unlock = 0
Else
Print ("{0} have beed locked because of trying password more than 3 times". Format (username))
#执行函数
Main ()
This article from "net580" blog, declined reprint!
Python First day assignment: writing the Login interface