Why am I getting this error when trying to urlencode this string
 >>> callback = "http://localhost/application/authtwitter?twitterCallback"  >>> urllib.urlencode(callback)  Traceback (most recent call last):       File "<stdin>", line 1, in <module>       File "/usr/lib/python2.7/urllib.py", line 1261, in urlencode       raise TypeError  TypeError: not a valid non-string sequence or mapping object 
                You can encode multiple parameters at once using urllib. parse. urlencode() function. This is a convenience function which takes a dictionary of key value pairs or a sequence of two-element tuples and uses the quote_plus() function to encode every value.
s = urllib2. quote(s) # URL encode. # Now "s" is encoded the way you need it. It works!
In Python, we can URL encode a query string using the urlib. parse module, which further contains a function urlencode() for encoding the query string in URL.
parse. urlencode() method can be used for generating the query string of a URL or data for a POST request.
That's not what that function does:
urlencode(query, doseq=0)     Encode a sequence of two-element tuples or dictionary into a URL query string.  Are you looking for?
urllib.quote(callback) Python 2urllib.parse.quote(callback)  Python 3If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With