擅长:python、mysql、java
<p>更简单:通过<a href="http://docs.python-requests.org/en/latest/index.html" rel="noreferrer">requests</a>模块。</p>
<pre><code>import requests
get_response = requests.get(url='http://google.com')
post_data = {'username':'joeb', 'password':'foobar'}
# POST some form-encoded data:
post_response = requests.post(url='http://httpbin.org/post', data=post_data)
</code></pre>
<p>若要发送非形式编码的数据,请将其序列化为字符串(示例取自<a href="http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests" rel="noreferrer">documentation</a>):</p>
<pre><code>import json
post_response = requests.post(url='http://httpbin.org/post', data=json.dumps(post_data))
# If using requests v2.4.2 or later, pass the dict via the json parameter and it will be encoded directly:
post_response = requests.post(url='http://httpbin.org/post', json=post_data)
</code></pre>