Python3.0 simulates user logon, three error locks, and python3.0 User Logon

Source: Internet
Author: User

Python3.0 simulates user logon, three error locks, and python3.0 User Logon
# -*- coding:utf-8 -*-# Simulate user logon as required. login is not allowed due to more than three error lockscount = 0 #realname passwdReal_Username = "test"Real_Password = "test" # Read contents from the blacklist= open('black_user','r')lock_file = f.read()f.close() Username = input('Enter the User name :') # Determine whether the user is in the blacklist. If the user is in the blacklist, the password cannot be entered.for in range(1):    if lock_file == Username:        print('Sorry, your user is locked and cannot be used now! ')        exit()    else:        continue # Try to enter the password and count the number of inputsfor in range(3):    Password = input("Enter the password :")    if Username == Real_Username and Password == Real_Password:        print("Logon successful")        break    else:        print("Logon Failed")    count += 1 # If three wrong passwords are entered, the system prompts that the user name is locked and the user name is blacklisted.if count == 3:    print("Sorry, the number of wrong passwords you entered has reached 3, and your user name will be locked")    = open("black_user","w")    f.write("%s"%Username)    f.close()

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.