-1
{
  "matching_results": 1264,
  "results": [
    {
      "main_image_url": "https://s4.reutersmedia.net/resources_v2/images/rcom-default.png",
      "enriched_text": {
        "entities": [
          {
            "relevance": 0.33,
            "disambiguation": {
              "subtype": [
                "Country"
              ]
            },
            "sentiment": {
              "score": 0
            },
            "type": "Location",
            "count": 1,
            "text": "China"
          },
          {
            "relevance": 0.33,
            "disambiguation": {
              "subtype": [
                "Country"
              ]
            },
            "sentiment": {
              "score": 0
            },

这是太大的文件,所以我想使用 python 找到“相关性”和“分数”。
如何获取此信息?

4

1 回答 1

2

不管它有多大,它只是一个简单的字典。

迭代列表。提取键值。

for result in data['results']:
    for e in result['enriched_text']['entities']:
        print(e['relevance'])
        print(e['sentiment']['score'])
于 2017-09-25T06:16:04.343 回答