博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python编写简单登陆认证
阅读量:7144 次
发布时间:2019-06-29

本文共 1132 字,大约阅读时间需要 3 分钟。

hot3.png

#!/usr/bin/env python#auther = shaw#ver = 1.3import startupaccount = {}acclist = []#产生账号信息字典with open('accountlist.txt','r+') as acc:   #accountlist.txt文件事先已被编写好,一行用户名,一行密码	for i in acc.readlines():		acclist.append(i.strip('\n'))for i in range(0,len(acclist),2):	name = acclist[i]	passwd = acclist[i+1]	account[name] = passwdi = 0status = False#判断主体while i <= 2:	name = raw_input('Please input your name:').strip()	with open('lock.txt','r+') as acclock:	# 判断账号是否被锁定begin		for f in acclock.readlines():			if  name == f.strip('\n'):				print '\033[31;2mSorry.you account has been locked.\033[0m'				status = True				break	if status is True:break		# 判断账号是否被锁定end	passwd = raw_input('Please input your passwd:').strip()	if account.has_key(name) and account[name] == passwd:	# 判断用户是否存在,以及此用户密码是否正确		print '### \033[32;2mLogin Succsss\033[0m.'		break	else:		i = i + 1		print '### \033[33;2myour name or passwd wrong\033[0m...'		continue# 用户名密码输入错误3次,锁定账号if i > 2:	print '\033[31;2mSorry.you account has been locked.\033[0m'	lock = file('lock.txt','a')	lock.write('%s\n'% name)	lock.close()

转载于:https://my.oschina.net/u/2428313/blog/486823

你可能感兴趣的文章
MyEclipse内存不足配置
查看>>
四舍五入网络Java保留两位小数
查看>>
MFC 循环界面假死的解决(MFC 按钮终止循环)
查看>>
详细解说九宫图比较常用的多控件布局
查看>>
程序员的出路在哪里?挣钱的机会来了续-福利来了,仿QQ界面,放出全部源码,打造创业框架及实现思路...
查看>>
C语言中的 (void*)0 与 (void)0
查看>>
DIV固定在页面某个位置,不随鼠标滚动而滚动
查看>>
android 根据SD卡中图片路径读取并显示SD中的图片——源代码
查看>>
浅析Android线程模型一 --- 转
查看>>
Cocos2d-x PluginX (二)增加新的Plugin
查看>>
python-django开发学习笔记四
查看>>
cocos2d-x开发记录:二,基本概念(导演,场景,层和精灵,场景切换,效果)...
查看>>
Binutils工具集中的一些比较常用的工具
查看>>
IoC在ASP.NET Web API中的应用
查看>>
Android手机 Fildder真机抓包
查看>>
jsp里面实现asp.net的Global文件内容。
查看>>
Oracle ROWID
查看>>
(转)为C# Windows服务添加安装程序
查看>>
使用Team Foundation Server 2012源代码管理基本
查看>>
WCF服务通信测试
查看>>