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