snipt

Ctrl+h for KB shortcuts

Python

POST in python

1
2
3
4
import urllib
data = urllib.urlencode(some_data_dict)
fd = urllib.urlopen(url, data)
fd.read()
https://snipt.net/embed/d0a0feffcb45185a527689c405c13bca/
/raw/d0a0feffcb45185a527689c405c13bca/
d0a0feffcb45185a527689c405c13bca
python
Python
4
2019-07-13T13:12:20
True
False
False
/api/public/snipt/870/
post-in-python
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kn">import</span> <span class="nn">urllib</span> </span><span id="L-2"><a name="L-2"></a><span class="n">data</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">urlencode</span><span class="p">(</span><span class="n">some_data_dict</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a><span class="n">fd</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a><span class="n">fd</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> </span></pre></div> </td></tr></table>
post, python, urllib