Job Requirements:
- Enter user name and password
- Login welcome message after successful authentication
- 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