user3782341
user3782341

Reputation: 1

parse through urllib2 in python

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

Answers (1)

Lix
Lix

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

Related Questions