login.py
#!/usr/bin/python
ufile=‘user.txt‘
lockfile=‘lock.txt‘
import tab,os
logincleck = False
loginlock = False
locknum=1
while True:
print "Input ID and Password.Please"
userid=raw_input("UserID:").strip()
userpass=raw_input("Password:").strip()
if len(userid) > 0 and len(userpass) > 0 :
break
while True :
f1=file(ufile)
f2=file(lockfile)
for f2line in f2.readlines():
if f2line.split()[0] == userid :
loginlock = True
break
else:
f2.close
if loginlock is True:
print "ERROR:ID is lock"
break
for f1line in f1.readlines():
if f1line.split()[0] == userid and f1line.split()[1] == userpass :
print "welcome %s " %userid
logincleck = True
break
if logincleck is True:
break
if locknum > 3 :
print "ERROR:password > 3 ,ID is lock"
f3=file(lockfile,‘a‘)
f3.write("%s\n" % userid)
f3.close
break
print "Error:ID or Password error.input password.please"
userpass=raw_input("Password:").strip()
locknum=locknum+1