Python User Login Program

Source: Internet
Author: User

Requirements: Let the user enter the user name password Authentication successful display welcome information after the error three after the exit program can support multiple users logged in the user 3 times authentication failed, quit the program, restart the program when you try to log on, or lock the state
#-*-coding:utf-8-*-#Author:skyellFlag=trueaccount_list= {'Xiaopang':'123','Haohao':'234'}#account PasswordUsername = input ('Please input your username:') Lock_name= Open ('Lockname_list.txt','R') forIinchLock_name:lockname=I.strip ()ifLockname = =Username:Print('your account has been locked!')         Break    Else:        Continuelock_name.close ()ifUsername! =Lock_name:password_wrong=0 whileFlag:password= Input ('Please input your password:') Acc_name= [keys forKeysinchAccount_list]#use list generation to deposit account information into the list        ifUsernameinchAcc_name:ifAccount_list[username] = = Password:#determine if the account and password are correct                Print('Welcome back!') Flag=False Break            Else:                Print('Please try again!') Password_wrong+=1ifPassword_wrong==3:#password Error 3 times, lock user                    Print('your account has been locked') Lock_name= Open ('Lockname_list.txt','A +') Lock_name.write ('\ n') Lock_name.write (username)#write the locked account to the locked filelock_name.close ()Else:            Print('Account was not found') Flag=False Break

Basic implementation requirements, continue to continue!

Python User Login Program

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.