擅长:python、mysql、java
<p>POST body</em>被设置为<code>ON</code>;使用<code>data</code>参数:</p>
<pre><code>import requests
headers = {"Content-Type": "text/plain"}
url = 'http://example.com/rest/items/z12'
res = requests.post(url, auth=('demo', 'demo'), data="ON", headers=headers)
</code></pre>
<p><code>params</code>参数用于URL查询参数,通过使用字典,您要求{<cd4>}将其编码为表单编码;因此,<code>?ON=</code>被添加到URL中。在</p>
<p>参见<a href="http://curl.haxx.se/docs/manpage.html" rel="nofollow">^{<cd6>} manpage</a>:</p>
<blockquote>
<p>(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button.</p>
</blockquote>
<p>以及<a href="http://docs.python-requests.org/en/latest/api/#main-interface" rel="nofollow">^{<cd4>} API</a>:</p>
<blockquote>
<p>data – (optional) Dictionary, bytes, or file-like object to send in the body of the <code>Request</code>.</p>
</blockquote>