AttributeError("'str' object has no attribute 'read'",)
This means exactly what it says: something tried to find a .read
attribute on the object that you gave it, and you gave it an object of type str
(i.e., you gave it a string).
The error occurred here:
json.load (jsonofabitch)['data']['children']
Well, you aren't looking for read
anywhere, so it must happen in the json.load
function that you called (as indicated by the full traceback). That is because json.load
is trying to .read
the thing that you gave it, but you gave it jsonofabitch
, which currently names a string (which you created by calling .read
on the response
).
Solution: don't call .read
yourself; the function will do this, and is expecting you to give it the response
directly so that it can do so.
You could also have figured this out by reading the built-in Python documentation for the function (try help(json.load)
, or for the entire module (try help(json)
), or by checking the documentation for those functions on http://docs.python.org .