Requirements:
1. Enter User name password
2. Display welcome information after successful authentication
3. After entering three times, lock the account
Flow chart:
Code implementation:
#!/usr/bin/env python
#! -*-Coding:utf-8-*-
#!--Author:freem---
Import OS
def auths (Username,password):
For I in range (3): #循环3次, 3 login authentication
User=input ("Please insert username:")
Pswd=input ("Please insert password:")
if (User==username and Pswd==password): #判断输入用户名和密码是否跟系统用户名密码匹配
Os.system (' CLS ')
Print ("\ n") #登陆成功!
Print ("*******************************************")
Print ("*welcome to Index,you inserted is correct!*")
Print ("*******************************************")
Break #如果认证成功退出整个循环
Elif (User==username):
Print ("Please ensure your password!") #密码错误
Else
Print ("Please ensure your username!") #用户名错误
Else
Print ("You have been locked!") #账户被锁
If __name__== "__main__":
Username= "Freem"
Password= "123"
Auths (Username,password) #调用auths函数
Implementation results:
Input three failed, the account is locked:
Enter the wrong password once and enter the correct user name and password:
After entering the correct user name and password, the welcome message is displayed!
Python Implements Login interface