Beginner Python3-Write a login program

Source: Internet
Author: User

This article mainly implements a simple login program, the default is to give an account password, put out the code to write and the process encountered problems.

----------------------------------------requirements are as follows:

Username

passwd

Let the user enter the account and password, enter the user and password to enter the correct words

prompt you xxx, welcome login, today's date is XXX, program end

Error, prompt account/Password input error

Enter up to 3 times, and if you enter 3 times, you are not logged in successfully, and the number of failed prompts is too large.

You need to determine if the input is empty, input null is also counted as an input error once

---------------------------------

The main problems encountered in the process are:

1. The Strip () method is required to determine that the input is empty

2. When printing the date, you need to format the%s in string format. The first time I used the%d format, the error format is incorrect

The code is as follows:

 import datetimecount =0while count<3:username = input ("Username:" PWD = input ("Password:") Dayt = Datetime.date.today () #print (Dayt) if username.strip () = = "or pwd.strip () = =        "": Print ("Your input is null,please input again!") Count=count+1 Continue elif Username = = "Julie" and pwd = = "123456": Print ("%s, welcome login, today's date is:%s, program end"% (US Ername,dayt)) Break Else:print ("Account/Password input error") Count = Count + 1else:print ("You have tried 3 Tim ES, the user has been locked! ")  

Beginner Python3-Write a login program

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.