python 登陆接口
#!/usr/bin/env python
import sys
name = ''
pw=''
name_num = 0
pw_num = 0
#black_list = []
with open('a.txt','r') as f:
for i in f.xreadlines():
namelist.append(i.split()[0])
pwlist.append(i.split()[1]) def name_test(input_name, namelist):
if input_name in namelist:
return True
else:
return False name = raw_input('Please input your name:')
name_num +=1
while True:
if name_test(name, namelist):
break
else:
if name_num < 3:
name = raw_input('Name is error,Please input your name again:')
name_num += 1
else:
print 'Sorry,Today you have mistyped user name three times'
sys.exit() pw = raw_input('Please input your password:')
pw_num +=1
while True:
index_pw = pwlist[namelist.index(name)]
if pw == index_pw:
print 'welcome'
break
else:
if pw_num < 3:
pw = raw_input('Passwd is error,Please input your passwd again:')
pw_num +=1
else:
print 'Sorry,Today you have to lose the wrong password three times'
sys.exit() 这里的a.txt的格式是
bao 123
zhang 456 后面还要加入黑名单的一些小程序 这里还有一个朋友给我的程序,感觉他的更加的简练,看着舒服:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2016/7/29 11:46
# @Author : Big_Bao
import sys
def name_test(input_name, namelist):
if input_name in namelist:
return True
else:
print 'Name is None.'
return False def pw_test(pw ,index_pw, innerloopnumber=0):
if pw == index_pw:
print 'Welcome.'
inn = innerloopnumber+1
return inn
else:
print 'Password is None.' namelist = []
pwlist = []
with open('a.txt','r') as f:
for i in f.xreadlines():
namelist.append(i.split()[0])
pwlist.append(i.split()[1]) index_pw = []
name = ''
pw=''
name_num = 0
pw_num = 0
inloopnum = 0 name = raw_input('Please input your name:')
name_num +=1
while True:
if name_test(name, namelist):
index_pw = pwlist[namelist.index(name)]
pw = raw_input('Please input your password:')
pw_num +=1
inloopnum_ = pw_test(pw, index_pw,innerloopnumber=inloopnum)
else:
name = raw_input('Please input your name again:')
name_num +=1 if name_num ==3:
print 'You have no chance.'
sys.exit()
if pw_num==3:
print 'You have no chance'
sys.exit()
if inloopnum_==1:
sys.exit() 感谢这位远在成都的朋友平时的指点
python 登陆接口的更多相关文章
- python——登陆接口设计(循环方法)
近日重新整理了登陆接口设计程序,感觉以前的代码没有注释,让园子的其他童鞋读起来比较费劲.也没有流程图和程序运行说明. 1.流程图 2.user_file.txt&lock_file.txt文件 ...
- python登陆接口编写
#coding:utf-8 import getpass,sys i=0 j=0 while i<3: username=raw_input('username:') #输入用户名 life_1 ...
- python 作业 编写登陆接口
# -*- coding:utf-8 -*-import os,sysfor i in range(3):#进行3次循环 blacklist = open(r"C:\Users\Pc4\De ...
- Python小程序之用户登陆接口
编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定 程序逻辑图: 代码: #!/usr/bin/env python #_*_ coding:UTF-8 _*_ #__author_ ...
- 使用 Python 编写登陆接口
# 使用 Python 编写登陆接口# Create Date: 2017.10.31 Tuesday# Author: Eric Zhao# -*- coding:utf-8 -*-'''编写登陆接 ...
- python - 登陆验证的滑块接口
----------------- 滑块接口 ----------------- 0:大体思路:点击登陆按钮的时候会进行第一次验证(滑块验证),然后访问后台滑块接口,并返回验证结果,如果滑块接口通 ...
- python之编写登陆接口(第一天)
作业:编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定 针对此实例写了有二种类型的脚本,略有不同,具体如下: 帐号文件account.txt内容如下: sam 123 david ...
- Python学习之编写登陆接口(Day1,作业一)
作业一:编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定(下次登陆还是锁定) 知识点:while循环,for循环,文件操作,if判断,列表操作 思路: 1.登陆,三次登陆失败,锁定 ...
- 不用框架,原生使用python做注册接口/登陆接口/充值接口的测试,做的数据/代码分离
注意充值时候,cookie的处理方法,还是原来的三种方法 1.操作数据文件 do_exclel.py # -*- conding:utr-8 -*- #@Time :2018/11/8 22:46 ...
随机推荐
- 贤者时间太久了么?--MySQL继续玩
hi 给自己放了大概三天的假,没有一点点防备,没有一点点准备,无意的 是不是贤者时间过不去了我不知道啊...继续看东西吧 1.MySQL -----运算符和函数----- 字符函数,数值运算符,比较运 ...
- GTAC 2015 的视频和文档已经放出
视频见https://developers.google.com/google-test-automation-conference/2015/stream,文档见https://developers ...
- Maven系列三Maven内置变量
Maven内置变量说明: ${basedir} 项目根目录(即pom.xml文件所在目录) ${project.build.directory} 构建目录,缺省为target目录 ${project. ...
- 转:软件架构入门 (from 阮一峰)
说明:其中讲到了 5 种的架构模型,很不错. from: http://www.ruanyifeng.com/blog/2016/09/software-architecture.html
- UIDate(时间)
1.时间与时间的比较 ["时间1" timeIntervalSinceDate:"时间2"] >= 0;
- 准备NOIP2017 最长公共子序列(模版)
一些概念: (1)子序列: 一个序列A = a1,a2,--an,中任意删除若干项,剩余的序列叫做A的一个子序列.也可以认为是从序列A按原顺序保留任意若干项得到的序列.例如: 对序列 1,3,5, ...
- Linux Linux下特殊的printf函数和fputs函数
Linux下,printf函数必须以'\n'结尾才会立刻输出到屏幕,如果没有'\n'直到输出缓冲区满了以后才会打印到屏幕上(敲击换行也算),如果需要不换行的输出,一般可以使用write函数代替.'\n ...
- 数据库Mark.2
select count(*) as count,DATE_SUB('2016-10-04',INTERVAL regDay DAY) from result_1005 group by DATE_S ...
- hadoop 2.6伪分布安装
hadoop 2.6的“伪”分式安装与“全”分式安装相比,大部分操作是相同的,主要区别在于不用配置slaves文件,而且其它xxx-core.xml里的参数很多也可以省略,下面是几个关键的配置: (安 ...
- windows下安装git & 在git@OSC上推送代码
第一部分 windows下安装git 1.下载最新版本的git:直接百度“git”,如图所示,点击立即下载. 也可以直接在官网下载最新版本的git:http://www.git-scm.com/dow ...