我在麻煩與BING的JSON API。JSON與BIN數據解碼問題(Python)
這裏是JSON數據我從api.bing.net/json.aspx接收:
{"SearchResponse":{"Version":"2.2","Query":{"SearchTerms":"news"},"Translation":{"Results":[{"TranslatedTerm":"Noticias"}]}}}
我需要解析TranslatedTerm值「消息報」,但它似乎我有一個問題與JSON解碼。我使用這個..
result = j.loads(bytes)
print result['SearchResponse']['Translation']['Results']
和Python給了我這樣的:
[{u'TranslatedTerm': u'Noticias'}]
如果我添加使用這樣的:
result['SearchResponse']['Translation']['Results']["TranslatedTerm"]
Python會引發像
print result['SearchResponse']['Translation']['Results']["TranslatedTerm"]
錯誤
TypeError:列表索引必須是int egers
我該如何獲得'Noticias'作爲純字符串?很多appriciated ...