I am trying to get the content to print as a python list. But it says json.loads(page) needs to be a string? When I use pythonlist = page.json() it works. Why is that? Should I never use json.loads() and always use .json()?
page = requests.get(“https://api.datamuse.com/words?ml=ringing+in+the+ears”)
pythonlist = json.loads(page)
What is the type of
json() method of response, that is shipped with Requests library, does loading for you. If you don’t want to use this shortcut, you can do:
pythonlist = json.loads(page.content)
page is a response object that has other attributes than sole content.
Got you. That makes sense. Also I believe I can do:
pythonlist = json.loads(page.text)
Instead of page.content, page.text also works. Is there a reason I should use the one over the other?