使用 Python 编写登陆接口

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用 Python 编写登陆接口相关的知识,希望对你有一定的参考价值。

# 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 编写登陆接口的主要内容,如果未能解决你的问题,请参考以下文章

python之编写登陆接口

python 编写登陆接口

python作业:编写登陆接口

Python编写登陆接口

(Python)编写登陆接口

python之编写登陆接口(第一天)