Python 3.0 simulates user logon and implements three error locks.

Source: Internet
Author: User

Python 3.0 simulates user logon and implements three error locks.

Python is an interpreted, object-oriented, and dynamic data type high-level programming language.

Python was invented by Guido van rosum at the end of 1989. The first public release was released in 1991.

Like Perl, Python source code also complies with the GPL (GNU General Public License) protocol.

Python 3.0 is often called Python 3000 or Py3k. Compared with earlier versions of Python, this is a major upgrade. In order not to bring too much effort into it, Python 3.0 was not designed with backward compatibility considerations.

The following is an example of code. We will introduce python 3.0 to simulate user logon and implement three error locks. The Code is as follows:

#-*-Coding: UTF-8-*-# simulate user logon as required, logon count = 0 # realname passwdReal_Username = "test" Real_Password = "test" # Read blacklisted content f = open ('black _ user ', 'R') lock_file = f. read () f. close () Username = input ('enter User name: ') # judge whether the input user is in the blacklist. If so, the password for I in range (1) is not allowed ): if lock_file = Username: print ('Sorry, your user is locked and is not allowed for use now! ') Exit () else: continue # try to enter the Password and count the number of inputs for I 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 user name is locked, and the user name is blacklisted. if count = 3: print ("sorry, the number of wrong password attempts you have entered has reached 3, and your user name will be locked ") f = open ("black_user", "w") f. write ("% s" % Username) f. close ()

Summary

The above is a small series of python 3.0 simulated user login function and three error locks, I hope to help you, if you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.