Reputation: 1
I want to convert following statement from urllib
to urllib2
equivalent statement
params = urllib.parse.urlencode( {'status': msg} )
I can import only urllib2
and urlparse
.
Upvotes: 0
Views: 2044
Reputation: 47966
urllib2
is not really the "2nd version" of urllib
. It's not possible to "translate" all functionality from urllib
to urllib2
.
Even the documentation for urllib2
states that you should use urllib
for URL encoding.
Extracted from the urllib2.urlopen
documentation:
...data should be a buffer in the standard application/x-www-form-urlencoded format. The
urllib.urlencode()
function takes a mapping or sequence of 2-tuples and returns a string in this format.
Upvotes: 1