# -*- coding:utf-8 -*-
# Author:joycezhou
import os,sys,getpass
count = 0
while count < 3:
username = input("请输入用户名:")
lock_file = open('account_lock.txt','r+')
lock_list = lock_file.readlines()
for lock_line in lock_list:
lock_line = lock_line.strip('
')
if username == lock_line:
print('用户名%s已经被锁定'% username)
sys.exit(1)
user_file = open('account.txt','r')
user_list = user_file.readlines()
print (user_list)
for user_line in user_list:
(user,passwd) = user_line.strip('
').split()
if username == user:
# print(username)
p = 0
while p <3:
print(username)
password = input("password:")
if password == passwd:
print("欢迎%s登录系统"%username)
sys.exit(1)
else:
if p != 2:
print('用户%s密码错误,请重新输入,还有%d机会' % (username,2-p))
p += 1
else:
lock_file.write(username + '
')
sys.exit("对不起%s用户已被锁定,请联系管理员" % username)
else:
pass
else:
if count != 2:
print('对不起,%s 输入错误,请重新输入,您还有%d 次机会' % (username , 2-count))
count += 1
else:
sys.exit('用户%s不存在,退出' % username)