Python Job User Login _day01

Source: Internet
Author: User

Job Requirements:

    1. Enter user name and password
    2. Login welcome message after successful authentication
    3. Password input error three times lock account

Ideas:

Draw the flowchart first, you can figure out the logic.

Created User_file is a user file, Lock_file is a locked user file

Main program:

1 #_*_ coding:utf-8 _*_2 __author__='Zhangkai'3 Print('**************** Welcome to the League of Legends ******************')4Login_user = input ('Please enter your account number:')5 6Lock_file = open ('Lock_file','r+')#open a locked user file path7Lock_list = Lock_file.readlines ()#read the entire file8  forLock_infoinchLock_list:#Traverse List9Lock = Lock_info.split ()#Remove Empty linesTen #Print (lock) One     ifLogin_user = = Lock[0]:#determine if the account is in a locked file A         Print('account has been locked! ') - exit () -  theLock_file.close ()#Close File -  -  -User_file = open ('User_file','r+') +User_list =User_file.readlines () -  forUser_infoinchuser_list: +user =User_info.split () A #print (user) at     ifLogin_user = =User[0]: -Count = 0#variable set a number of cycles -          whileCount <3:#cycles up to three times -LOGIN_PASSWD = input ('Please enter your password:') -             iflogin_passwdinchUSER[1]:#if it is equal to the preset password will continue to execute -                 Print('the enemy has 30 seconds to get to the battlefield and crush them! ') in #print (count) - exit () to             Else: +Count + = 1 -                 Print('Password input error, you have%d chances'% (3-count))#indicates the number of times remaining the #print (count) *         Else: $Lock_file.write (Login_user +'\ n')#write the locked account to a filePanax NotoginsengExit'account has been locked') -  the Else: +     Print('account does not exist cannot be empty or numeric') A exit () theUser_file.close ()

Register and unlock the user did not engage, write to write on the chaos, in the whole continue to improve ~

Python Job User Login _day01

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.