# _*_ encoding:utf-8 _*_
import json import requests #post请求
payload = {"cindy":"hello world",
"python":""} r = requests.post('http://httpbin.org/post',data=payload)
print (r.text)
#输出结果,data数据传输到form里面
# {
# "args": {},
# "data": "",
# "files": {},
# "form": {
# "cindy": "hello world",
# "python": "1078370383"
# },
# "headers": {
# "Accept": "*/*",
# "Accept-Encoding": "gzip, deflate",
# "Connection": "close",
# "Content-Length": "35",
# "Content-Type": "application/x-www-form-urlencoded",
# "Host": "httpbin.org",
# "User-Agent": "python-requests/2.18.4"
# },
# "json": null,
# "origin": "211.140.31.50",
# "url": "http://httpbin.org/post"
# } #把payload转换为json格式,post的body是json类型
data_json = json.dumps(payload)
r1 = requests.post('http://httpbin.org/post',data=data_json)
print (r1.text)
#输出结果,返回结果传回到data里
# {
# "args": {},
# "data": "{\"python\": \"1078370383\", \"cindy\": \"hello world\"}",
# "files": {},
# "form": {},
# "headers": {
# "Accept": "*/*",
# "Accept-Encoding": "gzip, deflate",
# "Connection": "close",
# "Content-Length": "48",
# "Host": "httpbin.org",
# "User-Agent": "python-requests/2.18.4"
# },
# "json": {
# "cindy": "hello world",
# "python": "1078370383"
# },
# "origin": "211.140.31.50",
# "url": "http://httpbin.org/post"
# }

Python接口自动化--requests 2的更多相关文章

  1. 【python接口自动化-requests库】【三】优化重构requests方法

    一.重构post请求方法 上一张讲了如何使用requests库发送post请求,但是有时候,我们写脚本,不可能这么简单,代码完全不可复用,重复工作,那我们是不是可以想象,把我们的get,post请求, ...

  2. 【python接口自动化-requests库】【二】requests库简单使用(入门)

    一.post请求 前面讲了,我们get请求的时候,引入requests的包,然后直接使用get方法,那么post是不是一样的? 1.首先我们先引入requests import requests 2. ...

  3. 【python接口自动化-requests库】【一】requests库安装

    1.概念 requests 是用Python语言编写,基于 urllib,采用 Apache2 Licensed 开源协议的 HTTP 库.它比 urllib 更加方便,可以节约我们大量的工作,完全满 ...

  4. Python接口自动化--requests 1

    # _*_ encoding:utf-8 _*_ import requests #请求博客园首页,无参数的get请求 r = requests.get('http://www.cnblogs.com ...

  5. python接口自动化(十)--post请求四种传送正文方式(详解)

    简介 post请求我在python接口自动化(八)--发送post请求的接口(详解)已经讲过一部分了,主要是发送一些较长的数据,还有就是数据比较安全等.我们要知道post请求四种传送正文方式首先需要先 ...

  6. python接口自动化-Cookie_绕过验证码登录

    前言 有些登录的接口会有验证码,例如:短信验证码,图形验证码等,这种登录的验证码参数可以从后台获取(或者最直接的可查数据库) 获取不到也没关系,可以通过添加Cookie的方式绕过验证码 前面在“pyt ...

  7. python接口自动化28-requests-html爬虫框架

    前言 requests库的好,只有用过的人才知道,最近这个库的作者又出了一个好用的爬虫框架requests-html.之前解析html页面用过了lxml和bs4, requests-html集成了一些 ...

  8. python接口自动化-参数化

    原文地址https://www.cnblogs.com/yoyoketang/p/6891710.html python接口自动化 -参数关联(一)https://www.cnblogs.com/11 ...

  9. python接口自动化 -参数关联(一)

    原文地址https://www.cnblogs.com/yoyoketang/p/6886610.html 原文地址https://www.cnblogs.com/yoyoketang/ 原文地址ht ...

随机推荐

  1. 【原】Solr入门之概念和安装

    Apache Solr 是Apache Lucene项目的开源企业搜索平台.其主要功能包括全文检索.命中标示.分面搜索.动态聚类.数据库集成,以及富文本(如Word.PDF)的处理.Solr是高度可扩 ...

  2. Java读取excel(兼容03和07格式)

    读取excel,首先需要下载POI的jar,可以去官网下,也可以在这里下载 一.简单说明 excel2003和excel2007区别比较大,最直观的感受就是扩展名不一样,哈哈 不过,使用POI的API ...

  3. NIO学习笔记七:Pipe

    Java NIO 管道是2个线程之间的单向数据连接.Pipe有一个source通道和一个sink通道.数据会被写到sink通道,从source通道读取. 这里是Pipe原理的图示: 示例代码 Pipe ...

  4. js 微信支付

    引入 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0. ...

  5. element-ui input组件源码分析整理笔记(六)

    input 输入框组件 源码: <template> <div :class="[ type === 'textarea' ? 'el-textarea' : 'el-in ...

  6. SD从零开始29-30

    SD从零开始29 外向交货单处理中的特殊功能 批次Batches 你可以在material handled in batches的相关详细屏幕指定一个batch(物料是否使用batches来处理标记在 ...

  7. SD从零开始03-04

    [原创]SD从零开始3 SD中的主数据 客户主数据Customer master(分层维护) 一般数据general data: 与销售和财务都有关,对所有的组织单元有效: 销售区域数据sales a ...

  8. SQLServer 学习笔记之超详细基础SQL语句 Part 5

    Sqlserver 学习笔记 by:授客 QQ:1033553122 -----------------------接Part 4------------------- 21使用默认 默认(也称默认值 ...

  9. 8 张脑图入门 JavaScript - 基础面试不倒

    8 张脑图入门 JavaScript - 基础面试不倒 转载请注明出处 第一:JavaScript 的变量 第二:JavaScript 运算符 第三:JavaScript 数组 第四:JavaScri ...

  10. JAVA 实现 QQ 邮箱发送验证码功能(不局限于框架)

    JAVA 实现 QQ 邮箱发送验证码功能(不局限于框架) 本来想实现 QQ 登录,有域名一直没用过,还得备案,好麻烦,只能过几天再更新啦. 先把实现的发送邮箱验证码更能更新了. 老规矩,更多内容在注释 ...