Python Job User Login _ day01, python_day01

Source: Internet
Author: User

Python Job User Login _ day01, python_day01

Job Requirements:

Ideas:

First, draw a flowchart. You can clarify the logic.

The created user_file is a user file, and the lock_file is a Locked User File.

Main Program:

1 # _ * _ coding: UTF-8 _ * _ 2 _ author _ = 'hangzhou' 3 print ('****************** welcome to League of legends ** ****************') 4 login_user = input ('enter your account: ') 5 6 lock_file = open ('lock _ file', 'r + ') # Open the Locked User File Path 7 lock_list = lock_file.readlines () # Read the entire file 8 for lock_info in lock_list: # traverse List 9 lock = lock_info.split () # Remove blank lines 10 # print (lock) 11 if login_user = lock [0]: # determine whether the account is in the locked file 12 print ('account is locked! ') 13 exit () 14 15 lock_file.close () # close the file 16 17 18 user_file = open ('user _ file', 'r +') 19 user_list = user_file.readlines () 20 for user_info in user_list: 21 user = user_info.split () 22 # print (user) 23 if login_user = user [0]: 24 count = 0 # variable set the number of cycles 25 while count <3: # Up to three cycles 26 login_passwd = input ('enter your password :') 27 if login_passwd in user [1]: # if the password is equal to the preset password, 28 print will continue to be executed ('enemies will arrive at the battlefield in 30 seconds and crush them! ') 29 # print (count) 30 exit () 31 else: 32 count + = 133 print ('incorrect password, you still have % d chances '% (3-count) # number of remaining reminders 34 # print (count) 35 else: 36 lock_file.write (login_user +' \ n ') # Write the locked account to the file 37 exit ('account locked ') 38 39 else: 40 print ('account does not exist cannot be blank or number ') 41 exit () 42 user_file.close ()

The registration and unlocking users are not involved, and the writing will be messy, and the entire process will continue to be improved ~

 

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.