Python impersonate three user logins, login failed to lock account and write to file

Source: Internet
Author: User

Login Requirements:

1, user input login account, password, login successful display welcome User login Interface

2, the user can try to log in three times, three login failed, will lock the user, and output to the new file.

Count = 0while count < 3 :    file1 = open (" Accounts.txt ", " R ")     data1 = file1.read (). Strip (). Split ()      username = input ("please input your username>>>> ")     password = input ("please input your password>>>>   ")     if username == data1[0] and password ==  Data1[1]:        print ("Welcom to %s login"  % username)         break;    elif username  == data1[2] and password == data1[3]:         print ("Welcom to %s login"  % username)          break;    elif username == data1[4] and password == data1[5]:         print ("Welcom to %s login"  % username)          break;    else:         print ("User  %s login is failure please try again"  %  username)     count = count + 1else:    file2  = open ("Lock_userlist.txt",  "W")     file2.write (username)      print ("you have try 3 times your %s is locked\n"  % Username

Accounts.txt


Test: Login Successful


Test: Login Failed

Python impersonate three user logins, login failed to lock account and write to file

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.