# _*_ 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. VS 通用产品密钥

    BWG7X-J98B3-W34RT-33B3R-JVYW9 HMGNV-WCYXV-X7G9W-YCX63-B98R2 HM6NR-QXX7C-DFW2Y-8B82K-WTYJV

  2. VB.NET的MsgBox

    一.可用按钮(指定消息框显示哪些按钮) MsgBoxStyle.OkOnly = vbOKOnly = 0(确定按钮) MsgBoxStyle.OkCancel = vbOKCancel = 1(确定 ...

  3. Java虚拟机 - Class类文件结构

    [深入Java虚拟机]之二:Class类文件结构 平台无关性 Java是与平台无关的语言,这得益于Java源代码编译后生成的存储字节码的文件,即Class文件,以及Java虚拟机的实现.不仅使用Jav ...

  4. javascript中常见错误类型

    js中控制台报错主分两大类: 第一类:语法错误,这一类错误在javascript预解析的过程中如果遇到,则会导致整个js文件都无法执行. 另一类:统称为异常,这一类的错误会导致在错误出现的那一行之后的 ...

  5. LeetCode DB : Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  6. 自定义data-*

    HTML5的自定义属性data-*详细介绍和JS操作实例 < div id="user" data-id="123456" data-name=" ...

  7. 帆软发布大数据直连引擎FineDirect,对焦大数据BI

    摘要:近日,帆软官方正式发布大数据直连引擎FineDirect模块.通过该模块,企业在应用FineBI原有功能的基础上,可直接对接现有数据源,无论是传统的关系型数据库,还是Hadoop生态圈.Mpp构 ...

  8. AsyncTask POST请求

    布局: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint. ...

  9. Flutter Dart中的异步

    以下内容从官网得到: https://webdev.dartlang.org/articles/performance/event-loop Even-Looper Dart是单线程模型,也就没有了所 ...

  10. CountDownTimer 源码分析

    倒计时的功能,比如说:发送短信验证码倒计时. public class CountDownTimerActivity extends Activity { private Button mSend; ...