Python First day assignment: writing the Login interface

Source: Internet
Author: User

#-*-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

Related Article

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.