Python-based login interface and python-based interface

Source: Internet
Author: User

Python-based login interface and python-based interface

Job: Write the login interface

  • Enter user name and password
  • Welcome information displayed after successful authentication
  • Lock after three wrong attempts
Use = [] # define an empty list to blacklist the file user. in the log user name writing list, dic = {'gaoqiang ': '000000', 'shanghai': '000000', 'laowan': '000000', 'laogao ': '20140901', 'laofeng ': '000000' }## account information is stored in a dictionary. Here, you can query and write the dictionary from the txt file. luck_num = 0 # The initial value is pulled three times by entering the password count once. blacklist function dic_list = list (dic. keys () # display the list in the form of a list. while True: user = input ("Enter the user name:") f = open ('user. log', 'R') for line in f. readlines (): # from user. log reads the username line = line in the blacklist. strip () use. append (Line) # Add the result to the empty use list. close () # print (use) if user in dic_list and user not in use: # Start to judge whether the input user name is in dict_list and whether it is in the blacklist while True: password = input ('Enter the password :') # if both of the above conditions are met, you need to add ''to the dictionary password to start to lose the password. Otherwise, the int type and string type cannot be compared or you can add int () while not password to the input. strip (): # If you enter null, the system prompts you to continue entering password = input ('Enter the password again :') luck_num + = 1 # enter the initial password value once and Add 1 p = dic [user] # Find the password corresponding to the input account if password = p: print ('Welcome in !! ') Quit () # exit the program elif luck_num> 2: f = open ('user. log', 'A') # When the number of inputs exceeds three, the user is written to the user. f. write (user + '\ n') f. close () print ('your account has been disabled; contact Customer Service 123456') quit () # exit the program else: print ('enter your password incorrectly ') elif user in dic and user in use: print ('your account % s has been disabled, please change') % user) f. close () else: print ('the account you entered is incorrect. Please enter it again ')

 

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.