dict object is not callable on json, requests modu

So, you are using the amazing requests module of Python! So checked their sample code in the website: http://docs.python-requests.org/en/latest/ and the URL you are calling returns json content. So you followed their example and came up with a code like this:import requestsurl = '' # put your url herer = requests.get(url)json_content = r.json()print json_contentWhen you run the program, you get the following error:

json_content = r.json()TypeError: 'dict' object is not callable

Now you are wondering what is this! An example from the home page doesn’t work. So you searched Google and came to my website. Now you solve the problem using json_content = r.json instead of json_content = r.json()So this code with work (Python 2.7):import requestsurl = '' # put your url herer = requests.get(url)json_content = r.jsonprint json_contentIf you are wondering why you got the error in the first code, let me give you a hint. Add the following lines to your Python code and see the output:print type(r)print type(r.json)

dict object is not callable on json, requests modu

相关文章:

你感兴趣的文章:

标签云: