cat account.txt ——用户密码名册
jack pass1
marry pass2
natasha pass3
touch lock.txt ——用户锁文件
cat login.py
#!/usr/bin/env python
import tab
#put account.txt infomation
f = file('account.txt')
account_list = f.readlines()
f.close()
f = file('lock.txt')
lock_list = []
for i in f.readlines():
line = i.strip()
lock_list.append(line)
f.close()
for i in range(3):
userlogin = False
name = raw_input('user:').strip()
if name in lock_list:
print 'sorry , you are already in the block list!'
continue
for line in account_list:
line = line.split()
if name == line[0]:
userlogin = True
for i in range(3):
password = raw_input('passwd:').strip()
if password == line[1]:
print "welcome logining %s's personal system!" % name
break
else:
f = file('lock.txt','a')
f.write('%s\n'%name)
f.close()
print 'sorry ,you are entered 3 times of wrong password , going to lock list!'
if userlogin == True: break