addinfourl实例没有属性'__getitem__'

时间:2019-06-23 04:27:22

标签: python urllib urllib2

我正在使用Python API绑定器获取步行得分(https://github.com/knockrentals/walkscore),以从地址获取步行得分。它在下面使用urllib。

from walkscore.api import WalkScore, TransitScore

apikey = ''
walkscore = WalkScore(apikey)

address = '1119 8th Avenue Seattle WA 98101'
lat = 47.6085
long = 122.3295

print walkscore.makeRequest(address, lat, long)



AttributeErrorTraceback (most recent call last)
<ipython-input-118-c72c48778cab> in <module>()
      8 long = 122.3295
      9 
---> 10 print walkscore.makeRequest(address, lat, long)

/Users//virt_env/virt1/lib/python2.7/site-packages/walkscore/api.pyc in makeRequest(self, address, lat, long)
     82         url = '%s=%s&%s&lat=%s&lon=%s&wsapikey=%s' % (self.apiUrl, self.format, urllib.urlencode({'address': address}), lat, long, self.apiKey)
     83         jsonResp, responseStatusCode = self._makeRequest(url)
---> 84         jsonRespStatusCode = jsonResp['status']
     85 
     86         # Error handling
AttributeError: addinfourl instance has no attribute '__getitem__'

我不知道为什么会出现此错误,因为我没有尝试索引响应。有什么建议吗?

0 个答案:

没有答案