I have written the following python script, using python requests (http://requests.readthedocs.org/en/latest/):
import requests
payload = {\'key1\': \'value 1\
I only find urllib.parse.quote , which can replace space to %20
.
But quote
could not convert a dict.
so, We must use quote
to transform dict in advance.
#for python3
from urllib.parse import quote
payload = {'key1': 'value 1', 'key2': 'value 2'}
newpayload = {}
for (k, v) in payload.items():
newpayload[quote(k)] = quote(v)
print(newpayload)
#print result: {'key1': 'value%20%201', 'key2': 'value%202'}
# Now, you can use it in requests