登陆接口程序

  • 输入用户名密码
  • 认证成功后显示欢迎信息
  • 数错三次后锁定
# Author: Mr.Xue
# 2019.10.20

import getpass
import pickle as p
import ast

count = 0
name = ''
filename1 = 'user.txt'
filename2 = 'user_lock.txt'
list_1 = []
list_2 = []

f1 = open(filename1, 'r')
infos1 = f1.read()
infos1_list = ast.literal_eval(infos1)
#print(infos1)
f1.close()
f2 = open(filename2, 'r')
infos2 = f2.read()
infos2_list = ast.literal_eval(infos2)
f2.close()
#print(infos2),
#print(type(infos2))

while count < 3:
	username = input("username: ")
	password = input("password: ")
	name = username
	list_2.append(name)
	list_2.append(password)
	#print(list_2)
	if name in infos2_list:
		print("lock...")
		break
	elif list_2 in infos1_list:
		print('Wlecome {_name} login...'.format(_name = username))
		break
	else:
		print("Invalid username or password.")
	count += 1	
else:
	print("your account have been locked.")	
	infos2_list.append(name)
	f2 = open(filename2, 'w')
	f2.write(str(infos2_list))
	f2.close()
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值