Python Multi-User Login

Source: Internet
Author: User

Demand:

    • Can support multiple users login (prompt, through the list to save multiple account information)
    • After the user 3 authentication failed, quit the program, start the program again when attempting to log on, or lock the status (hint: the user locked state must be stored in the file)

Flow chart:

Code:

1div={2 'List1':{'Password':'123456'},3 'List2':{'Password':'123456'},4 'List3':{'Password':'123456'},5 }6f = open ('Black_user','R')7Lock_file =F.readlines ()8 f.close ()9Count=0Tencount1=0 One  whileTrue: AName_input=input ("Please input name:") -     ifCount = = 3: -         Print("user name input number reached limit") the          Break -     if   notName_inputinchDiv: -             Print("User name Error") -Count +=1 +     ifName_inputinchLock_file: -         Print("the user name is locked and paused! ") + exit () A  at     ifName_inputinchDiv: -Count-=2 -PASSWORD_INPUT=STR (Input ("Please input password:")) -         ifPassword_input = = div[name_input]['Password']: -             Print("Password Successful") -              Break in         Else: -             Print("Password Error") toCount1 +=1 +         ifCount1 = = 2: -             Print("you have entered the wrong number of passwords 3 times, will lock your account!") thef = open ('Black_user','W') *F.write ('%s'%name_input) $ f.close ()Panax Notoginseng              Break

Python Multi-User Login

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.