I have a problem about urlencode in python 2.7:
>>> import urllib
>>> import json
>>> urllib.urlencode(json.dumps({'title':"hello world!",'anonymous':False,'needautocategory':True}))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/urllib.py", line 1280, in urlencode
raise TypeError
TypeError: not a valid non-string sequence or mapping object
Because
urllib.urlencode“converts a mapping object or a sequence of two-element tuples to a “percent-encoded” string…”. Your string is neither of these.I think you need
urllib.quoteorurllib.quote_plus.