# _*_ 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. CompletableFuture 专题

    /** * @Auther: cheng.tang * @Date: 2019/3/2 * @Description: */ package com.tangcheng.learning.concur ...

  2. EWS 流通知订阅邮件

    摘要 查找一些关于流通知订阅邮件的资料,这里整理一下. 核心代码块 using System; using System.Collections.Generic; using System.Linq; ...

  3. org.hibernate.HibernateException: Wrong column type

    这个问题一般出现在我们使用定长的字符串作为主键(其它字段也可能)的时候,如数据库中的ID为char(16).虽然很多资料上都说不推荐这样做,但实际上我们在做很多小case的时候自己为了方便也顾不得那么 ...

  4. async和await学习笔记

    结论: (1)asyc方法的返回类型必须为:void.Task或者Task<T>.返回类型为Task的异步方法中无需使用return返回值,而返回类型为Task<TResult> ...

  5. 【ZeroMQ】2、高性能的通讯库-zeroMQ

    首先,让我来介绍一下什么是ZMQ(全称:ZeroMQ): 官方: “ZMQ(以下ZeroMQ简称ZMQ)是一个简单好用的传输层,像框架一样的一个socket library,他使得Socket编程更加 ...

  6. Java 支付宝支付,退款,单笔转账到支付宝账户(单笔转账到支付宝账户)

    上次分享了支付宝订单退款的代码,今天分享一下支付宝转账的操作.  现在是有一个余额提现的功能,本来是打算做提现到银行卡的,但是客户嫌麻烦不想注册银联的开放平台账户,就说先提现到支付宝就行,二期再做银行 ...

  7. Oracle总结之plsql编程(基础八)

    原创作品,转自请注明出处:https://www.cnblogs.com/sunshine5683/p/10328524.html 一.函数 1.函数是可以返回一个特定的数据,函数的创建中必须包含re ...

  8. Crazy Shopping(拓扑排序+完全背包)

    Crazy Shopping(拓扑排序+完全背包) Because of the 90th anniversary of the Coherent & Cute Patchouli (C.C. ...

  9. 从零开始学习html(十五)css样式设置小技巧——上

    一.水平居中设置-行内元素 <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> ...

  10. 网络基础 HTTP协议之HTTP消息(HTTP Message)

    HTTP协议之HTTP消息(HTTP Message) by:授客 QQ:1033553122 1.   消息类型(Message Type) HTTP messages包含从客户端到服务器的请求和服 ...