I am trying to run following code but it is giving me below error:
Traceback (most recent call last): File \"put_message.py\", line 43, in tra
The urlencode
function does not take a single string as input, it takes a something like a dictionary.
data = urlencode({'key': apiKey, 'q': source_word, ...)
urllib2.urlopen("http://....", data)
From the Documentation,
urllib.urlencode(query[, doseq])
Convert a mapping object or a sequence of two-element tuples to a “percent-encoded” string, suitable to pass to urlopen() above as the optional data argument. This is useful to pass a dictionary of form fields to a POST request. The resulting string is a series of key=value pairs separated by '&' characters, where both key and value are quoted using quote_plus() above. When a sequence of two-element tuples is used as the query argument, the first element of each tuple is a key and the second is a value.