Python Implements Login interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.