Write so rotten, are embarrassed to start, later think after all is the first PY program, or at work time secretly written, take out to do a memorial it,
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/1C/wKiom1c4DPrzzKr-AACfV0QyuEs183.png "title=" OR Template.png "alt=" Wkiom1c4dprzzkr-aacfv0qyues183.png "/>
# -*- coding:utf-8 -*-#!/usr/bin/env pythonimport osimport os.pathusername = "Liulidong" password = "123456" K = 1for i in range (Ten): if not os.path.exists ('/tmp/lock.txt '): # determine if the dictionary file exists os.system ("Touch /tmp/lock.txt") output = open ('/tmp/lock.txt ', ' r ') # open dictionary file read = output.read () # Reading dictionary content arr= read.split (';') #以, separating, converting strings to arrays user = input ("please input your username: ") # Enter user name &nbsP; passwd = input ("please input your password: ") #输入密码 for n in range (0, len (arr)): if user == arr[n]: print ("your name is lock Please mail to administrator ") os._exit (1) #循环判断用户是否在字典中 if username == user and password == passwd: print ("Welcome to linux") #输入正确返回欢迎信息 break else: k+=1 print ("Your name or password is wrong") if k > 3: # output three records inside the file output = open ('/tmp/lock.txt ', ' a ') Output.write (user + '; ') output.close () print ("you test too many,your Username will be lock ") break
Please execute this script with Python3 under Linux
Python first day job login three error lock account