python 登陆接口 作业1
2017-12-15 22:11
344 查看
from collections import Counter ''' 登陆接口 ''' clean = input("clean Y or N:") if (clean == "Y" or clean=="y"): with open("lock.txt","w") as f: f.close() login_info='''欢迎登陆!''' f_read=open("user.txt","r") f_read_lock=open("lock.txt","r") user={} lock=[] for line in f_read: username, password= line.strip().split(",") user[username]=password print(user)#直接查看字典 for line in f_read_lock: lock.append(line.strip()) print(lock) #遍历字典 # for key in dict: # print(dict[key]) # for line in open("lock.txt","r"): # username, password= line.strip().split(",") # user[username]=password n=0 while(n<3): with open("lock.txt", "a") as f: input_name = input("name:") input_password = input("password:") f.write(input_name+"\n") f.close() count_user=Counter(lock) if input_name in count_user.keys() and count_user.get(input_name)>=3: print("账户锁定") break elif input_name in user and input_password == user[input_name]:#in 代替了 2.x has_key print(login_info) break else: print("账户名或密码错误"+"\n") n=n+1 if(n==3): print("输入大于三次,退出")
user.txt放入自己指定的用户名密码
相关文章推荐
- 【我们一起自学Python】-课后作业:编写登陆接口
- Python学习作业之登陆接口_For
- python_01作业(编写登陆接口)
- Python学习作业之登陆接口_While
- python登陆接口----运维开发初学
- python:编写登陆接口(day 1)
- Python-S13作业-day4-之登陆,管理后台
- python 登陆接口
- PYTHON自学手册--用户登陆接口
- python登陆接口以及流程图
- python 登陆接口
- python学习之登陆接口
- python之用户登陆作业
- python作业----编写登录接口
- Day1作业1:登陆接口(加入日志、注册功能)
- 【Python之旅】第一篇:基于文件处理的登陆接口
- Python-S13作业-day1-之登陆程序
- Python 登陆接口小程序V2
- Python 模拟系统登陆接口
- python之编写登陆接口(第一天)