摘要: 接口返回的为html,但是我们需要取其中的某些字段进行传递。 答 :可以使用 正则 进行读取 正则口诀:知道前后取中间,遇到字符加转义 例如,想取下图标红字段, import re import requests url = 'xxxxxxx' r = requests.get(url).text 阅读全文
posted @ 2020-03-11 19:38 dearddu 阅读(2012) 评论(0) 推荐(0) 编辑
摘要: 一、Session 关联 跨请求:比如登录之后发帖,这个发帖是依赖先登录的(需要传登录cookie) http协议是无状态的,也就是每个请求都是独立的。 那么登录后的一系列动作,都需要用cookie来验证身份是否是登录状态。 为了高效的管理会话,保持会话,于是就有了session 代码演示: 阅读全文
posted @ 2020-03-11 16:51 dearddu 阅读(228) 评论(0) 推荐(0) 编辑
摘要: import json dict = { 'xx':''123 } a = json.dumps(dict) # 字典转json print(type(a)) # 为 str 此时数据中 单引号变为双引号,Tuple -> list , Ture -> ture , None -> null jso 阅读全文
posted @ 2020-03-11 13:09 dearddu 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1、环境配置 如果是python3.6 对应pytest 4.5.0 (换成其他版本会有问题) 若是python3.7,对应pytest最新版本即可 pytest 5.x.x 安装: pip3 install pytest==xxx pip3 show pytest 查看相应版本号 2、用例设计规则 阅读全文
posted @ 2020-03-11 11:33 dearddu 阅读(178) 评论(0) 推荐(0) 编辑