【发布时间】:2015-12-14 14:46:22
【问题描述】:
我有一个获取和处理JsonData 的函数。我的代码是这样的:
def getData(link,row):
u=urllib2.urlopen(link).read();
jsonObject=json.loads(u);
# do some stuff
return (jsonObject[u'pagination']['next_url'],row);
json,newRow=getData("https://api.instagram.com/v1/tags/****/media/recent?access_token=*****",0);
while (len(json )!= 0):
json,newRow=getData(json,newRow);
当我第一次调用getData 函数时,它给了我正确的响应!但是当我在while 中第二次调用它时,我得到了这样的错误:
AttributeError: 'unicode' 对象没有属性 'loads'
有趣的是,第二次调用中的u 值是逻辑。它是这样的:
{"pagination":{"next_max_tag_id":"1139055135096994516","deprecation_warning":"next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id ............ }
为什么我在以后的函数调用中会出现这个错误?
【问题讨论】:
标签: python json python-2.7 url