在Python我收到一个错误:
Exception: (,
AttributeError("'str' object has no attribute 'read'",), )
给定python代码:
def getEntries (self, sub):
url = 'http://www.reddit.com/'
if (sub != ''):
url += 'r/' + sub
request = urllib2.Request (url +
'.json', None, {'User-Agent' : 'Reddit desktop client by /user/RobinJ1995/'})
response = urllib2.urlopen (request)
jsonofabitch = response.read ()
return json.load (jsonofabitch)['data']['children']
这个错误意味着什么,我做了什么导致它?