石昌士 發表於 2019-3-27 08:15:00

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

<h2>简介</h2>
<p>  post请求我在python接口自动化(八)--发送post请求的接口(详解)已经讲过一部分了,主要是发送一些较长的数据,还有就是数据比较安全等。我们要知道post请求四种传送正文方式首先需要先了解一下常见的四种编码方式:</p>
<p>HTTP 协议规定 POST 提交的数据必须放在消息主体(entity-body)中,但协议并没有规定数据必须使用什么编码方式。</p>
<h2>浏览器行为:Form表单提交</h2>
<h3>1、form表单常用属性</h3>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 0, 1)">action:url 地址,服务器接收表单数据的地址
</span><span style="color: rgba(0, 128, 128, 1)">2</span> <span style="color: rgba(0, 0, 0, 1)">method:提交服务器的http方法,一般为post和get
</span><span style="color: rgba(0, 128, 128, 1)">3</span> <span style="color: rgba(0, 0, 0, 1)">name:最好好吃name属性的唯一性
</span><span style="color: rgba(0, 128, 128, 1)">4</span> enctype: 表单数据提交时使用的编码类型,默认使用<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pplication/x-www-form-urlencoded</span><span style="color: rgba(128, 0, 0, 1)">"</span>,如果是使用POST请求,则请求头中的content-type指定值就是该值。如果表单中有上传文件,编码类型需要使用<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">multipart/form-data</span><span style="color: rgba(128, 0, 0, 1)">"</span>,类型,才能完成传递文件数据。</pre>
</div>
<p>enctype为form表单数据的编码格式,Content-type为Http传输的数据的编码格式。分清两者</p>
<h3>2、浏览器提交表单时,会执行如下步骤</h3>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 0, 1)">识别出表单中表单元素的有效项,作为提交项
</span><span style="color: rgba(0, 128, 128, 1)">2</span> <span style="color: rgba(0, 0, 0, 1)">构建一个表单数据集
</span><span style="color: rgba(0, 128, 128, 1)">3</span> 根据form表单中的enctype属性的值作为content-<span style="color: rgba(0, 0, 0, 1)">type对数据进行编码
</span><span style="color: rgba(0, 128, 128, 1)">4</span> 根据form表单中的action属性和method属性向指定的地址发送数据</pre>
</div>
<h3>3、提交方式</h3>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 255, 1)">get</span>:表单数据会被encodeURIComponent后以参数的形式:name1=value1&amp;name2=value2 附带在url?<span style="color: rgba(0, 0, 0, 1)">后面,再发送给服务器,并在url中显示出来。
</span><span style="color: rgba(0, 128, 128, 1)">2</span> post:enctype 默认<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">application/x-www-form-urlencoded</span><span style="color: rgba(128, 0, 0, 1)">"</span>对表单数据进行编码,数据以键值对在http请求体重发送给服务器;如果enctype 属性为<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">multipart/form-data</span><span style="color: rgba(128, 0, 0, 1)">"</span>,则以消息的形式发送给服务器。</pre>
</div>
<p>Http协议行为:Http1.1协议</p>
<p>我们知道,HTTP 协议是以 ASCII 码传输,建立在 TCP/IP 协议之上的应用层规范。规范把 HTTP 请求分为三个部分:状态行、请求头、消息主体。类似于下面这样:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> &lt;method&gt; &lt;request-URL&gt; &lt;version&gt; &lt;headers&gt; &lt;entity-body&gt;  </pre>
</div>
<p>  协议规定 POST 提交的数据必须放在消息主体(entity-body)中,但协议并没有规定数据必须使用什么编码方式。实际上,开发者完全可以自己决定消息主体的格式,只要最后发送的 HTTP 请求满足上面的格式就可以。</p>
<p>但是,数据发送出去,还要服务端解析成功才有意义。一般服务端语言如 php、python 等,以及它们的 framework,都内置了自动解析常见数据格式的功能。服务端通常是根据请求头(headers)中的 Content-Type 字段来获知请求中的消息主</p>
<p>体是用何种方式编码,再对主体进行解析。</p>
<p>所以说到 POST 提交数据方案,包含了 Content-Type 和消息主体编码方式两部分</p>
<h2>常见的四种编码方式如下:&nbsp;&nbsp;</h2>
<h3>1、application/x-www-form-urlencoded&nbsp;</h3>
<p>  这应该是最常见的 POST 提交数据的方式了。浏览器的原生 form 表单,如果不设置 enctype 属性,那么最终就会以 application/x-www-form-urlencoded 方式提交数据。请求类似于下面这样(无关的请求头在本文中都省略掉了):</p>
<div class="cnblogs_code">
<pre>POST http://www.example.com HTTP/1.1    <br>Content-Type:application/x-www-form-urlencoded;charset=utf-8
title=test&amp;sub%5B%5D=1&amp;sub%5B%5D=2&amp;sub%5B%5D=3</pre>
</div>
<p>  首先,Content-Type 被指定为 application/x-www-form-urlencoded;其次,提交的数据按照 key1=val1&amp;key2=val2 的方式进行编码,key 和 val 都进行了 URL 转码。大部分服务端语言都对这种方式有很好的支持。例如 PHP 中,</p>
<p>$_POST['title'] 可以获取到 title 的值,$_POST['sub'] 可以得到 sub 数组。</p>
<p>  很多时候,我们用 Ajax 提交数据时,也是使用这种方式。例如&nbsp;JQuery&nbsp;和&nbsp;QWrap&nbsp;的 Ajax,Content-Type 默认值都是「application/x-www-form-urlencoded;charset=utf-8」。</p>
<h3>2、multipart/form-data&nbsp;</h3>
<p>  除了传统的application/x-www-form-urlencoded表单,我们另一个经常用到的是上传文件用的表单,这种表单的类型为multipart/form-data。</p>
<p>  这又是一个常见的 POST 数据提交的方式。我们使用表单上传文件时,必须让 form 的 enctyped 等于这个值,下面是示例</p>
<p>form表单:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> &lt;form action=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/upload</span><span style="color: rgba(128, 0, 0, 1)">"</span> enctype=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">multipart/form-data</span><span style="color: rgba(128, 0, 0, 1)">"</span> method=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">post</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">2</span>   Username: &lt;input type=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(128, 0, 0, 1)">"</span> name=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">username</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">3</span>   Password: &lt;input type=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">password</span><span style="color: rgba(128, 0, 0, 1)">"</span> name=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">password</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">4</span>   File: &lt;input type=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">file</span><span style="color: rgba(128, 0, 0, 1)">"</span> name=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">file</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">5</span>   &lt;input type=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">submit</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">6</span> &lt;/form&gt;</pre>
</div>
<p>Http协议请求:</p>
<div class="cnblogs_code">
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
<pre>POST http://www.example.com HTTP/1.1
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryrGKCBY7qhFd3TrwA
------WebKitFormBoundaryrGKCBY7qhFd3TrwA
Content-Disposition: form-data; name="text"
title
------WebKitFormBoundaryrGKCBY7qhFd3TrwA
Content-Disposition: form-data; name="file"; filename="chrome.png"
Content-Type: image/png
PNG ... content of chrome.png ...
------WebKitFormBoundaryrGKCBY7qhFd3TrwA--</pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
</div>
<p>  这个例子稍微复杂点。首先生成了一个 boundary 用于分割不同的字段,为了避免与正文内容重复,boundary 很长很复杂。然后 Content-Type 里指明了数据是以 multipart/form-data 来编码,本次请求的 boundary 是什么内容。消息主体里</p>
<p>按照字段个数又分为多个结构类似的部分,每部分都是以&nbsp;<code>--boundary</code>&nbsp;开始,紧接着是内容描述信息,然后是回车,最后是字段具体内容(文本或二进制)。如果传输的是文件,还要包含文件名和文件类型信息。消息主体最后以&nbsp;<code>--boundary-</code></p>
<p><code>-</code>&nbsp;标示结束。关于 multipart/form-data 的详细定义,请前往&nbsp;rfc1867&nbsp;查看。</p>
<p>这种方式一般用来上传文件,各大服务端语言对它也有着良好的支持。</p>
<p>  上面提到的这两种 POST 数据的方式,都是浏览器原生支持的,而且现阶段标准中原生 &lt;form&gt; 表单也只支持这两种方式(通过 &lt;form&gt; 元素的&nbsp;<code>enctype</code>&nbsp;属性指定,默认为&nbsp;<code>application/x-www-form-urlencoded</code>。其实&nbsp;<code>enctype</code>&nbsp;还支</p>
<p>持&nbsp;<code>text/plain</code>,不过用得非常少)。</p>
<p>  随着越来越多的 Web 站点,尤其是 WebApp,全部使用 Ajax 进行数据交互之后,我们完全可以定义新的数据提交方式,给开发带来更多便利。</p>
<h3>3、application/json&nbsp;</h3>
<p>  application/json 这个 Content-Type 作为响应头大家肯定不陌生。实际上,现在越来越多的人把它作为请求头,用来告诉服务端消息主体是序列化后的 JSON 字符串。由于 JSON 规范的流行,除了低版本 IE 之外的各大浏览器都原生支持</p>
<p>JSON.stringify,服务端语言也都有处理 JSON 的函数,使用 JSON 不会遇上什么麻烦。</p>
<p>  JSON 格式支持比键值对复杂得多的结构化数据,这一点也很有用。记得我几年前做一个项目时,需要提交的数据层次非常深,我就是把数据 JSON 序列化之后来提交的。不过当时我是把 JSON 字符串作为 val,仍然放在键值对里,以 x-</p>
<p>www-form-urlencoded 方式提交。</p>
<p>  Google 的&nbsp;AngularJS&nbsp;中的 Ajax 功能,默认就是提交 JSON 字符串。例如下面这段代码:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 255, 1)">var</span> data = {<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(128, 0, 0, 1)">'</span>:<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">'</span>, <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">sub</span><span style="color: rgba(128, 0, 0, 1)">'</span> : [<span style="color: rgba(128, 0, 128, 1)">1</span>,<span style="color: rgba(128, 0, 128, 1)">2</span>,<span style="color: rgba(128, 0, 128, 1)">3</span><span style="color: rgba(0, 0, 0, 1)">]};
</span><span style="color: rgba(0, 128, 128, 1)">2</span> <span style="color: rgba(0, 0, 0, 1)">$http.post(url, data).success(function(result) {
</span><span style="color: rgba(0, 128, 128, 1)">3</span> <span style="color: rgba(0, 0, 0, 1)">    ...
</span><span style="color: rgba(0, 128, 128, 1)">4</span> });</pre>
</div>
<p>最终发送的请求是:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> POST http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">www.example.com HTTP/1.1</span>
<span style="color: rgba(0, 128, 128, 1)">2</span> Content-Type: application/json;charset=utf-<span style="color: rgba(128, 0, 128, 1)">8</span>
<span style="color: rgba(0, 128, 128, 1)">3</span>
<span style="color: rgba(0, 128, 128, 1)">4</span> {<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(128, 0, 0, 1)">"</span>:<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">test</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">sub</span><span style="color: rgba(128, 0, 0, 1)">"</span>:[<span style="color: rgba(128, 0, 128, 1)">1</span>,<span style="color: rgba(128, 0, 128, 1)">2</span>,<span style="color: rgba(128, 0, 128, 1)">3</span>]}</pre>
</div>
<pre><strong class="name">这种方案,可以方便的提交复杂的结构化数据,特别适合 RESTful 的接口。各大抓包工具如 Chrome 自带的开发者工具、Firebug、Fiddler,都会以树形结构展示 JSON 数据,非常友好。但也有些服务端语言还没有支持这种方式,例如 php 就无法通过 $_POST 对象从上面的请求中获得内容。这时候,需要自己动手处理下:在请求头中 Content-Type 为 application/json 时,从&nbsp;</strong></pre>
<pre><strong class="name"><code class="hljs less"><span class="hljs-attribute"><br>php:<span class="hljs-comment">//input</span></span></code>&nbsp;里获得原始输入流,再&nbsp;<code class="hljs">json_decode</code>&nbsp;成对象。一些 php 框架已经开始这么做了。</strong></pre>
<p>  当然 AngularJS 也可以配置为使用 x-www-form-urlencoded 方式提交数据。如有需要,可以参考这篇文章。</p>
<h3>4、text/xml&nbsp;</h3>
<p>  它是一种使用 HTTP 作为传输协议,XML 作为编码方式的远程调用规范。典型的 XML-RPC 请求是这样的:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> POST http:<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">www.example.com HTTP/1.1</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span> Content-Type: text/<span style="color: rgba(0, 0, 0, 1)">xml
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span> &lt;?xml version=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">1.0</span><span style="color: rgba(128, 0, 0, 1)">"</span>?&gt;
<span style="color: rgba(0, 128, 128, 1)"> 5</span> &lt;methodCall&gt;
<span style="color: rgba(0, 128, 128, 1)"> 6</span>   &lt;methodName&gt;examples.getStateName&lt;/methodName&gt;
<span style="color: rgba(0, 128, 128, 1)"> 7</span>   &lt;<span style="color: rgba(0, 0, 255, 1)">params</span>&gt;
<span style="color: rgba(0, 128, 128, 1)"> 8</span>         &lt;param&gt;
<span style="color: rgba(0, 128, 128, 1)"> 9</span>             &lt;value&gt;&lt;i4&gt;<span style="color: rgba(128, 0, 128, 1)">41</span>&lt;/i4&gt;&lt;/value&gt;
<span style="color: rgba(0, 128, 128, 1)">10</span>         &lt;/param&gt;
<span style="color: rgba(0, 128, 128, 1)">11</span>   &lt;/<span style="color: rgba(0, 0, 255, 1)">params</span>&gt;
<span style="color: rgba(0, 128, 128, 1)">12</span> &lt;/methodCall&gt;</pre>
</div>
<p>  XML-RPC 协议简单、功能够用,各种语言的实现都有。它的使用也很广泛,如 WordPress 的&nbsp;XML-RPC Api,搜索引擎的&nbsp;ping 服务等等。JavaScript 中,也有现成的库支持以这种方式进行数据交互,能很好的支持已有的 XML-RPC 服</p>
<p>务。不过,我个人觉得 XML 结构还是过于臃肿,一般场景用 JSON 会更灵活方便。</p>
<p>  相比之下,get方式的数据提交方式(编码方式)只有一种,就是application/x-www-form-urlencoding</p>
<h3>post请求四种传送正文方式:</h3>
<p>  (1)请求正文是application/x-www-form-urlencoded</p>
<p>  (2)请求正文是multipart/form-data</p>
<p>  (3)请求正文是raw</p>
<p>  (4)请求正文是binary</p>
<p><strong>(1)请求正文是application/x-www-form-urlencoded</strong></p>
<p>形式:</p>
<div class="cnblogs_code">
<pre>1 requests.post(url='',data={'key1':'value1','key2':'value2'},headers={'Content-Type':'application/x-www-form-urlencoded'})</pre>
</div>
<p>  Reqeusts支持以form表单形式发送post请求,只需要将请求的参数构造成一个字典,然后传给requests.post()的<code>data</code>参数即可。</p>
<p><img src="https://img2018.cnblogs.com/blog/1232840/201903/1232840-20190325150705328-1109426382.png" alt=""></p>
<p>  可以看到,请求头中的Content-Type字段已设置为application/x-www-form-urlencoded,且<code>d = {'key1': 'value1', 'key2': 'value2'}</code>以form表单的形式提交到服务端,服务端返回的form字段即是提交的数据。</p>
<p><strong>(2)请求正文是multipart/form-data</strong></p>
<p><strong>  除了传统的application/x-www-form-urlencoded表单,我们另一个经常用到的是上传文件用的表单,这种表单的类型为multipart/form-data。</strong></p>
<p>形式:</p>
<div class="cnblogs_code">
<pre>1 requests.post(url='',data={'key1':'value1','key2':'value2'},headers={'Content-Type':'multipart/form-data'})</pre>
</div>
<p>&nbsp;  发送文件中的数据需要(安装requests_toolbelt)</p>
<div class="cnblogs_code">
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
<pre>from requests_toolbelt import MultipartEncoder
import requests

m = MultipartEncoder(
    fields={'field0': 'value', 'field1': 'value',
            'field2': ('filename', open('file.py', 'rb'), 'text/plain')}
    )

r = requests.post('http://httpbin.org/post', data=m,
                  headers={'Content-Type': m.content_type})</pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
</div>
<p>  不需要文件</p>
<div class="cnblogs_code">
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
<pre>from requests_toolbelt import MultipartEncoder
import requests

m = MultipartEncoder(fields={'field0': 'value', 'field1': 'value'})

r = requests.post('http://httpbin.org/post', data=m,
                  headers={'Content-Type': m.content_type})</pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
</div>
<p><strong>(3)请求正文是raw</strong></p>
<p>形式:</p>
<pre>♦传入xml格式文本</pre>
<div class="cnblogs_code">
<pre>1 requests.post(url='',data='&lt;?xml?&gt;',headers={'Content-Type':'text/xml'})</pre>
</div>
<pre>♦传入json格式文本</pre>
<div class="cnblogs_code">
<pre>1 requests.post(url='',data=json.dumps({'key1':'value1','key2':'value2'}),headers={'Content-Type':'application/json'})</pre>
</div>
<p>或者:</p>
<div class="cnblogs_code">
<pre>1requests.post(url='',json={{'key1':'value1','key2':'value2'}},headers={'Content-Type':'application/json'})</pre>
</div>
<p>  可以将一json串传给requests.post()的data参数,</p>
<p><img src="https://img2018.cnblogs.com/blog/1232840/201903/1232840-20190325151237599-1481247332.png" alt=""></p>
<p><strong>(4)请求正文是binary</strong></p>
<p>形式:</p>
<div class="cnblogs_code">
<pre>1 requests.post(url='',files={'file':open('test.xls','rb')},headers={'Content-Type':'binary'})</pre>
</div>
<p>  Requests也支持以multipart形式发送post请求,只需将一文件传给requests.post()的<code>files</code>参数即可。</p>
<p>输入:</p>
<div class="cnblogs_code">
<pre>url = 'http://httpbin.org/post'
files = {'file': open('report.txt', 'rb')}
r = requests.post(url, files=files)
print r.text</pre>
</div>
<p>输出:</p>
<div class="cnblogs_code">
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
<pre>{
“args”: {},
“data”: “”,
“files”: {
“file”: “Hello world!”
},
“form”: {},
“headers”: {……
“Content-Type”: “multipart/form-data; boundary=467e443f4c3d403c8559e2ebd009bf4a”,
……
},
“json”: null,
……
}</pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></span></div>
</div>
<p>&nbsp;  文本文件report.txt的内容只有一行:Hello world!,从请求的响应结果可以看到数据已上传到服务端中。<span style="color: rgba(255, 0, 0, 1)">注意:一定要注意headers的类型。</span></p>

</div>
<div id="MySignature" role="contentinfo">
    <div id="MySignature" style="display: block">
        <div style="font-size: 13px; border: 1px dashed rgb(45, 161, 45); padding: 10px 15px; background-color: rgb(248, 248, 248)">
                <label style="font-weight: bold">
                        &nbsp;&nbsp;&nbsp;&nbsp;为了方便大家在移动端也能看到我分享的博文,现已注册个人微信公众号,扫描左下方二维码即可,欢迎大家关注,提前解锁更多测试干货!有时间会及时分享相关技术博文。
                </label>
                <br>
                <label style="font-weight: bold">
                        &nbsp;&nbsp;&nbsp;&nbsp;为了方便大家互动讨论相关技术问题,刚刚建立了咱们的专门的微信群交流互动群,群内会分享交流测试领域前沿知识。请您扫描中间的微信二维码进群
                </label>
                <br>
                <label style="font-weight: bold">
                        &nbsp;&nbsp;&nbsp;&nbsp;为了方便大家互动讨论相关技术问题,现已组建专门的微信群,由于微信群满100,请您扫描右下方宏哥个人微信二维码拉你进群
                        <label style="font-weight: bold; color: red; font-size: 15px">
                                (请务必备注:已关注公众号进群)平时上班忙(和你一样),所以加好友不及时,请稍安勿躁~
                        </label>
                        ,欢迎大家加入这个大家庭,我们一起畅游知识的海洋。
                </label>
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;感谢您花时间阅读此篇文章,如果您觉得这篇文章你学到了东西也是为了犒劳下博主的码字不易不妨打赏一下吧,让博主能喝上一杯咖啡,在此谢过了!
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;如果您觉得阅读本文对您有帮助,请点一下左下角
               
                        “推荐”
               
                按钮,您的
                <label style="font-weight: bold; color: red; font-size: 15px">
                        “推荐”
                </label>
                将是我最大的写作动力!另外您也可以选择
               
                        【
                        <strong>
                                关注我
                        </strong>
                        】
               
                ,可以很方便找到我!
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;本文版权归作者和博客园共有,来源网址:
               
                        https://www.cnblogs.com/du-hong
               
                欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利!
        </div>
        <div style="text-align: center; margin-top: 10px">
                <p style=" font-weight: bolder; color: red; ">
                        公众号(关注宏哥)&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace; &NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        微信群(扫码进群) &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;
                        &NonBreakingSpace;&NonBreakingSpace;&NonBreakingSpace; &NonBreakingSpace;&NonBreakingSpace;客服微信
                </p>
                <img style="width: 200px;padding-right: 50px;" alt="个人微信公众号" src="https://img2018.cnblogs.com/common/1741949/201911/1741949-20191119095948011-608816619.png">
                <img style="width: 200px;padding-right: 65px;" alt="微信群" src="https://img2024.cnblogs.com/blog/1232840/202506/1232840-20250610113707419-637869921.png">
                <img style="width: 200px" alt="个人微信" src="https://img2018.cnblogs.com/common/1741949/201911/1741949-20191106101257091-849954564.png">
        </div>
</div><br><br>
来源:https://www.cnblogs.com/du-hong/p/10592519.html
頁: [1]
查看完整版本: python接口自动化(十)--post请求四种传送正文方式(详解)