码迷,mamicode.com
首页 > 编程语言 > 详细

使用 Python 编写登陆接口

时间:2017-11-01 01:07:11      阅读:278      评论:0      收藏:0      [点我收藏+]

标签: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!‘)

使用 Python 编写登陆接口

标签:create   put   blacklist   pass   strip()   adl   python   sda   wro   

原文地址:http://www.cnblogs.com/abarcher/p/7764382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!