Python login account failed three times, automatic account lockout

Source: Internet
Author: User

Topic demand:

1. Enter the user name password

2. Display welcome message after successful authentication

3. Three times after the wrong lock

Username= "Zhangsunan"
Passwd= "123456"
Count=0

With open ("blacklist", Mode= "R", encoding= "UTF8") as F: #打开黑名单
L_list=f.readlines ()

While Count < 3:
Name = input ("Please enter user name")
PWD = input ("Please enter a password")
If name = = Username and pwd = = passwd:
Print ("Welcome login")
Break
If name in L_list: #判断是否在黑名单里
Print ("Your account is locked")
Break
Else
Print ("Bad password")
Count + = 1
if Count = = 3:
Print ("You have entered more than three times, the account is locked")
With open ("blacklist", mode= ' A + ', encoding= "UTF8") as F:
Test = ("\n%s"% name)
F.write (Test)
Print ("User name error")
Insufficient: Only the third input user can be locked

Python login account failed three times, automatic account lockout

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.