Python 3.5 User Login authentication and enter three password lock users

Source: Internet
Author: User

1 #!/usr/bin/env python2 #Encoding:utf-83 #Login program, enter user and password output welcome information, input error three times lock user, do not let login4 ImportSYS5 Print(" "6 Welcome to our system.7 " ")8 9Pass_file = open ('Passwd.txt','R')TenClok_file = open ('Clok.txt','R') One  AName_list = [] -Clok_list = [] -Name_dict = {} the  forIinchPass_file: -Name, passwd = I.strip ('\ n'). Split (':') - name_list.append (name) -Name_dict[name] =passwd + pass_file.close () -  forIinchClok_file: +Clok_list.append (I.strip ('\ n')) A clok_file.close () at #print (clok_list) -  -num = 1 -Name = input ('Please input your name:') - ifNameinchclok_list: -     Print('your name is Clok, peasle system admin') in sys.exit () - ifNameinchname_dict: to      whileNum <=3: +passwd = input ('Please input your passwd:') -         ifpasswd = =Name_dict[name]: the             Print('Welcome to WO system') *              Break $         Else:Panax Notoginseng             Print('Pass Error') -num + = 1 the Else: +     Print('User no system') A  the ifnum > 3: +     Print('your name is Clok, peasle system admin') -f = open ('Clok.txt','a') $F.write (name +'\ n') $F.close ()

Passwd.txt files by format

User name: Password

User Name 2: password

Clok.txt file format

User Name 1

User Name 2

Python 3.5 User Login authentication and enter three password lock users

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.