1
很多類似的問題,但我似乎可以得到最簡單的情況下工作。更多simplejson AttributeError:'unicode'對象沒有任何屬性'get'
代碼是:
retval = urllib2.Request(callstr)
opener = urllib2.build_opener()
f = opener.open(retval)
json = simplejson.load(f)
for item in json:
print item.get("ExtActionResponse.info")
JSON對象似乎得到正確填充。
json
ExtActionRepsonse <dict ox7122345...>
info u"345167273\n1234:56768" <----- This is the data I'm expecting
resultCode u"0"
resultStr u"Success"
...etc...
但它扼殺在獲得項目調用。
print item.get("ExtActionResponse.info")
感謝
嘗試:'import pprint' then,'pprint.pprint(json)'加載後。讓我們看看你實際上有什麼數據。我認爲問題可能是你需要做一些像'item.get('ExtActionResponse',{})。get('info')' – sberry