Python: urllib2.urlopen(url, data) Why do you have to urllib.urlencode() the data? -
I thought a post had sent all the information in the HTTP header when you used the post ( But it's not a good idea, obviously), so I'm confused that you have to change the data to key = value & amp; Why urlencode () in the key2 = value2
format why is this format used when using POST?:
#Failed data = {'name': 'John Smith '} Urllib2.urlopen (foo_url, data)
but
# successful data = {' name ':' John Smith '} data = urllib. Urlencode (data) urllib2.urlopen (foo_url, data)
This "content-type "Is related to the header: The client should know how the post data is encoded or otherwise how it is deco Right?
The standard way to do this is via the encoding format application / x-www-form-urlencoded .
Now, if the question is "Why do we need to encode?" So the answer is "because we should be able to portray the payload in the HTTP container."
Comments
Post a Comment