Python-day1 Writing the Login interface

Source: Internet
Author: User

Flow chart:

Code:

1 #Author:p J J2 #Create two new files, one called User_lock.txt, one called User.txt, enter the user name and password in user.txt such as: PJJ 123 If more than one user is required, after entering a user3 #Enter a second user4Count=05  whileCount<3:6Username = input ("Please enter user name:")7F1 = open ('User_lock.txt','r+')8Lock_list =F1.readlines ()9 Ten      forLock_userinchlock_list: OneLock_user = Lock_user.strip ('\ n') A         ifusername==Lock_user: -             Print("User%s has been blacklisted. Program Exit"%username) - exit () theF2 = open ("User.txt","R") -File_list =F2.readlines () -      forLineinchfile_list: -User,pwd=line.strip ("\ n"). Split () +  -         ifusername==User: +Count2=0 A                  whileCount2<3: atPassword=input ("Please enter your password:") -                     ifpassword==pwd: -                         Print("Login Successful") - exit () -                     Else: -                         ifCount2<2: in                             Print("Password input Error! , you can also enter%d times"% (2-count2)) -Count2+=1 to                         Else: +F1.write (username +'\ n') -                             Print("error entering your password 3 times, your account has entered the blacklist") the exit () *  $     Else:Panax Notoginseng         ifCount < 2: -             Print('the%s entered does not exist and can be entered%d times'% (username, 2-count)) theCount + = 1 + Else: A     Print("%s user does not exist, program exits! "%username) the  + f1.close () -F2.close ()

Two new. txt files

User name, password, enumerated in User.txt

Python-day1 Writing the Login interface

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.