标签:create put blacklist pass strip() adl python sda wro
# Create Date: 2017.10.31 Tuesday
# Author: Eric Zhao
# -*- coding:utf-8 -*-
‘‘‘
编写登陆接口
输入用户名密码
认证成功后显示欢迎信息
输错三次后锁定
‘‘‘
login_user = input(‘Please input user name..‘)
# obj_u = ‘\‘‘+login_user+‘\‘‘
# print(obj_u)
password = input(‘Please input password..‘)
users = open(‘users.txt‘)
obj_users = eval(users.readline())
# print(type(obj_users))
blacklist = open(‘blacklist.txt‘)
# print(type(blacklist))
‘‘‘
line = blacklist.readline()
bl = line.rstrip()
print(bl+‘ bl‘)
blacklist.close()
‘‘‘
for line in blacklist:
bl = line.rstrip()
if bl == login_user:
print(login_user + ‘ is locked!‘)
blacklist.close()
break
else:
blacklist.close()
count = 0
if login_user in obj_users:
print(login_user + ‘ is valid account.‘)
if password == obj_users.get(login_user):
print(‘Welcome ‘ + login_user + ‘.‘)
else:
while count <= 1:
password = input(‘The password is wrong,Please input again:‘)
if password == obj_users.get(login_user):
print(‘Welcome ‘ + login_user + ‘.‘)
break
count += 1
else:
print(‘Your account has been locked!‘)
blacklist = open(‘blacklist.txt‘, ‘w‘)
blacklist.write(login_user +‘\n‘)
blacklist.close()
else:
print(login_user + ‘ does not exist!‘)
标签:create put blacklist pass strip() adl python sda wro
原文地址:http://www.cnblogs.com/abarcher/p/7764382.html