使用python

时间:2018-02-13 13:06:23

标签: python json twitter tweets data-extraction

我正在尝试使用以下代码从json文件中提取名为text的特定字段属性。

python代码:

    import json
    jsonFile = open('search.json', 'r')
    values = json.load(jsonFile)
    jsonFile.close()
    print(values['tweetdata']['retweeted_status']['text'])

JSON文件如下所示:

    {"tweetdata":{
"contributors": null,
"coordinates": null,
"created_at": "Tue Jan 30 14:26:58 +0000 2018",
"entities": {
    "hashtags": [],
    "symbols": [],
    "urls": [],
    "user_mentions": [
        {
            "id": 29526123,
            "id_str": "29526123",
            "indices": [
                3,
                13
            ],
            "name": "Siva #swachhbharat",
            "screen_name": "muthushiv"
        }
    ]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 958345800127401984,
"id_str": "958345800127401984",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"place": null,
"retweet_count": 2,
"retweeted": false,
"retweeted_status": {
    "contributors": null,
    "coordinates": null,
    "created_at": "Tue Jan 30 13:56:22 +0000 2018",
    "entities": {
        "hashtags": [],
        "symbols": [],
        "urls": [
            {
                "display_url": "twitter.com/i/web/status/9\u2026",
                "expanded_url": "https://twitter.com/i/web/status/958338098605080577",
                "indices": [
                    117,
                    140
                ],
                "url": ""
            }
        ],
        "user_mentions": []
    },
    "favorite_count": 2,
    "favorited": false,
    "geo": null,
    "id": 958338098605080577,
    "id_str": "958338098605080577",
    "in_reply_to_screen_name": null,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "is_quote_status": false,
    "lang": "en",
    "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
    },
    "place": null,
    "possibly_sensitive": false,
    "retweet_count": 2,
    "retweeted": false,
    "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
    "text": "Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is",
    "truncated": true,
    "user": {
        "contributors_enabled": false,
        "created_at": "Tue Apr 07 19:49:08 +0000 2009",
        "default_profile": false,
        "default_profile_image": false,
        "description": "Inquisitive free man who loves life. \nRT is not an endorsement.\nI love everyone. My tweets r meant to question my own understanding!",
        "entities": {
            "description": {
                "urls": []
            }
        },
        "favourites_count": 18421,
        "follow_request_sent": false,
        "followers_count": 1239,
        "following": false,
        "friends_count": 1651,
        "geo_enabled": false,
        "has_extended_profile": false,
        "id": 29526123,
        "id_str": "29526123",
        "is_translation_enabled": false,
        "is_translator": false,
        "lang": "en",
        "listed_count": 17,
        "location": "white plains, NY",
        "name": "Siva #swachhbharat",
        "notifications": false,
        "profile_background_color": "BADFCD",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_tile": false,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/29526123/1513447624",
        "profile_image_url": "http://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_link_color": "FF0000",
        "profile_sidebar_border_color": "F2E195",
        "profile_sidebar_fill_color": "FFF7CC",
        "profile_text_color": "0C3E53",
        "profile_use_background_image": true,
        "protected": false,
        "screen_name": "muthushiv",
        "statuses_count": 22905,
        "time_zone": "Europe/London",
        "translator_type": "none",
        "url": null,
        "utc_offset": 0,
        "verified": false
    }
},
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"text": "RT @muthushiv: Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is not a re\u2026",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Fri Jan 01 13:41:09 +0000 2016",
    "default_profile": true,
    "default_profile_image": false,
    "description": "A Science Enthusiast. RTs not an Endorsement.",
    "entities": {
        "description": {
            "urls": []
        }
    },
    "favourites_count": 9395,
    "follow_request_sent": false,
    "followers_count": 596,
    "following": false,
    "friends_count": 196,
    "geo_enabled": false,
    "has_extended_profile": false,
    "id": 4689495258,
    "id_str": "4689495258",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "en",
    "listed_count": 23,
    "location": "",
    "name": "\u0b86\u0ba9\u0bcd\u0bae\u0bc0\u0b95 \u0b85\u0bb0\u0b9a\u0bbf\u0baf\u0bb2\u0bcd\ud83c\uddee\ud83c\uddf3",
    "notifications": false,
    "profile_background_color": "F5F8FA",
    "profile_background_image_url": null,
    "profile_background_image_url_https": null,
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "Mr_Mannagatti",
    "statuses_count": 27802,
    "time_zone": "Stockholm",
    "translator_type": "none",
    "url": null,
    "utc_offset": 3600,
    "verified": false
}}}

这样做时我得到正确的输出:

Best way to erase a religion is by calling it a "Heritage". Jallikattu is not a religion, but a Heritage. Pongal is… 

但是当JSON文件中的属性tweetdata包含多个值时,exceution将失败。 示例JSON文件:

        {
"contributors": null,
"coordinates": null,
"created_at": "Tue Jan 30 14:26:58 +0000 2018",
"entities": {
    "hashtags": [],
    "symbols": [],
    "urls": [],
    "user_mentions": [
        {
            "id": 29526123,
            "id_str": "29526123",
            "indices": [
                3,
                13
            ],
            "name": "Siva #swachhbharat",
            "screen_name": "muthushiv"
        }
    ]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 958345800127401984,
"id_str": "958345800127401984",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"place": null,
"retweet_count": 2,
"retweeted": false,
"retweeted_status": {
    "contributors": null,
    "coordinates": null,
    "created_at": "Tue Jan 30 13:56:22 +0000 2018",
    "entities": {
        "hashtags": [],
        "symbols": [],
        "urls": [
            {
                "display_url": "twitter.com/i/web/status/9\u2026",
                "expanded_url": "https://twitter.com/i/web/status/958338098605080577",
                "indices": [
                    117,
                    140
                ],
                "url": ""
            }
        ],
        "user_mentions": []
    },
    "favorite_count": 2,
    "favorited": false,
    "geo": null,
    "id": 958338098605080577,
    "id_str": "958338098605080577",
    "in_reply_to_screen_name": null,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "is_quote_status": false,
    "lang": "en",
    "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
    },
    "place": null,
    "possibly_sensitive": false,
    "retweet_count": 2,
    "retweeted": false,
    "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
    "text": "Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is",
    "truncated": true,
    "user": {
        "contributors_enabled": false,
        "created_at": "Tue Apr 07 19:49:08 +0000 2009",
        "default_profile": false,
        "default_profile_image": false,
        "description": "Inquisitive free man who loves life. \nRT is not an endorsement.\nI love everyone. My tweets r meant to question my own understanding!",
        "entities": {
            "description": {
                "urls": []
            }
        },
        "favourites_count": 18421,
        "follow_request_sent": false,
        "followers_count": 1239,
        "following": false,
        "friends_count": 1651,
        "geo_enabled": false,
        "has_extended_profile": false,
        "id": 29526123,
        "id_str": "29526123",
        "is_translation_enabled": false,
        "is_translator": false,
        "lang": "en",
        "listed_count": 17,
        "location": "white plains, NY",
        "name": "Siva #swachhbharat",
        "notifications": false,
        "profile_background_color": "BADFCD",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_tile": false,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/29526123/1513447624",
        "profile_image_url": "http://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_link_color": "FF0000",
        "profile_sidebar_border_color": "F2E195",
        "profile_sidebar_fill_color": "FFF7CC",
        "profile_text_color": "0C3E53",
        "profile_use_background_image": true,
        "protected": false,
        "screen_name": "muthushiv",
        "statuses_count": 22905,
        "time_zone": "Europe/London",
        "translator_type": "none",
        "url": null,
        "utc_offset": 0,
        "verified": false
    }
},
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"text": "RT @muthushiv: Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is not a re\u2026",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Fri Jan 01 13:41:09 +0000 2016",
    "default_profile": true,
    "default_profile_image": false,
    "description": "A Science Enthusiast. RTs not an Endorsement.",
    "entities": {
        "description": {
            "urls": []
        }
    },
    "favourites_count": 9395,
    "follow_request_sent": false,
    "followers_count": 596,
    "following": false,
    "friends_count": 196,
    "geo_enabled": false,
    "has_extended_profile": false,
    "id": 4689495258,
    "id_str": "4689495258",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "en",
    "listed_count": 23,
    "location": "",
    "name": "\u0b86\u0ba9\u0bcd\u0bae\u0bc0\u0b95 \u0b85\u0bb0\u0b9a\u0bbf\u0baf\u0bb2\u0bcd\ud83c\uddee\ud83c\uddf3",
    "notifications": false,
    "profile_background_color": "F5F8FA",
    "profile_background_image_url": null,
    "profile_background_image_url_https": null,
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "Mr_Mannagatti",
    "statuses_count": 27802,
    "time_zone": "Stockholm",
    "translator_type": "none",
    "url": null,
    "utc_offset": 3600,
    "verified": false
}},{
"contributors": null,
"coordinates": null,
"created_at": "Tue Jan 30 14:01:19 +0000 2018",
"entities": {
    "hashtags": [],
    "symbols": [],
    "urls": [],
    "user_mentions": [
        {
            "id": 29526123,
            "id_str": "29526123",
            "indices": [
                3,
                13
            ],
            "name": "Siva #swachhbharat",
            "screen_name": "muthushiv"
        }
    ]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 958339345219436544,
"id_str": "958339345219436544",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"place": null,
"retweet_count": 2,
"retweeted": false,
"retweeted_status": {
    "contributors": null,
    "coordinates": null,
    "created_at": "Tue Jan 30 13:56:22 +0000 2018",
    "entities": {
        "hashtags": [],
        "symbols": [],
        "urls": [
            {
                "display_url": "twitter.com/i/web/status/9\u2026",
                "expanded_url": "https://twitter.com/i/web/status/958338098605080577",
                "indices": [
                    117,
                    140
                ],
                "url": ""
            }
        ],
        "user_mentions": []
    },
    "favorite_count": 2,
    "favorited": false,
    "geo": null,
    "id": 958338098605080577,
    "id_str": "958338098605080577",
    "in_reply_to_screen_name": null,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "is_quote_status": false,
    "lang": "en",
    "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
    },
    "place": null,
    "possibly_sensitive": false,
    "retweet_count": 2,
    "retweeted": false,
    "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
    "text": "Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is",
    "truncated": true,
    "user": {
        "contributors_enabled": false,
        "created_at": "Tue Apr 07 19:49:08 +0000 2009",
        "default_profile": false,
        "default_profile_image": false,
        "description": "Inquisitive free man who loves life. \nRT is not an endorsement.\nI love everyone. My tweets r meant to question my own understanding!",
        "entities": {
            "description": {
                "urls": []
            }
        },
        "favourites_count": 18421,
        "follow_request_sent": false,
        "followers_count": 1239,
        "following": false,
        "friends_count": 1651,
        "geo_enabled": false,
        "has_extended_profile": false,
        "id": 29526123,
        "id_str": "29526123",
        "is_translation_enabled": false,
        "is_translator": false,
        "lang": "en",
        "listed_count": 17,
        "location": "white plains, NY",
        "name": "Siva #swachhbharat",
        "notifications": false,
        "profile_background_color": "BADFCD",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_tile": false,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/29526123/1513447624",
        "profile_image_url": "http://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_link_color": "FF0000",
        "profile_sidebar_border_color": "F2E195",
        "profile_sidebar_fill_color": "FFF7CC",
        "profile_text_color": "0C3E53",
        "profile_use_background_image": true,
        "protected": false,
        "screen_name": "muthushiv",
        "statuses_count": 22905,
        "time_zone": "Europe/London",
        "translator_type": "none",
        "url": null,
        "utc_offset": 0,
        "verified": false
    }
},
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"text": "RT @muthushiv: Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is not a ",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Wed Jul 08 05:02:36 +0000 2009",
    "default_profile": true,
    "default_profile_image": false,
    "description": "For the protection of the righteous, for the destruction of wicked, and for the establishment of Dharma, I am born in every age. \u0b95\u0bbf\u0bb0\u0bc1\u0bb7\u0bcd\u0ba3\u0bbe\u0bb0\u0bcd\u0baa\u0bcd\u0baa\u0ba3\u0bae\u0bcd.",
    "entities": {
        "description": {
            "urls": []
        }
    },
    "favourites_count": 3633,
    "follow_request_sent": false,
    "followers_count": 79,
    "following": false,
    "friends_count": 138,
    "geo_enabled": false,
    "has_extended_profile": false,
    "id": 54804923,
    "id_str": "54804923",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "en",
    "listed_count": 0,
    "location": "",
    "name": "Sai Sakthi",
    "notifications": false,
    "profile_background_color": "C0DEED",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/952740575924514816/ef9fWKQz_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/952740575924514816/ef9fWKQz_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "RishyaShringar",
    "statuses_count": 1250,
    "time_zone": "New Delhi",
    "translator_type": "none",
    "url": null,
    "utc_offset": 19800,
    "verified": false
}},

代码失败,错误显示为

   Traceback (most recent call last):
   File "C:\Users\SJ\Desktop\New folder\parse.py", line 3, in <module>
   values = json.load(jsonFile)
   File "E:\Program files\python\lib\json\__init__.py", line 291, in load
   **kw)
   File "E:\Program files\python\lib\json\__init__.py", line 339, in loads
   return _default_decoder.decode(s)
   File "E:\Program files\python\lib\json\decoder.py", line 364, in decode
   obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   File "E:\Program files\python\lib\json\decoder.py", line 382, in 
   raw_decode
   raise ValueError("No JSON object could be decoded")
   ValueError: No JSON object could be decoded

可以理解如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

看起来你有一个tweetdata列表。像。的东西。

{"tweetdata" :[{
"contributors": null,
"coordinates": null,
"created_at": "Tue Jan 30 14:26:58 +0000 2018",
"entities": {
    "hashtags": [],
    "symbols": [],
    "urls": [],
    "user_mentions": [
        {
            "id": 29526123,
            "id_str": "29526123",
            "indices": [
                3,
                13
            ],
            "name": "Siva #swachhbharat",
            "screen_name": "muthushiv"
        }
    ]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 958345800127401984,
"id_str": "958345800127401984",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"place": null,
"retweet_count": 2,
"retweeted": false,
"retweeted_status": {
    "contributors": null,
    "coordinates": null,
    "created_at": "Tue Jan 30 13:56:22 +0000 2018",
    "entities": {
        "hashtags": [],
        "symbols": [],
        "urls": [
            {
                "display_url": "twitter.com/i/web/status/9\u2026",
                "expanded_url": "https://twitter.com/i/web/status/958338098605080577",
                "indices": [
                    117,
                    140
                ],
                "url": ""
            }
        ],
        "user_mentions": []
    },
    "favorite_count": 2,
    "favorited": false,
    "geo": null,
    "id": 958338098605080577,
    "id_str": "958338098605080577",
    "in_reply_to_screen_name": null,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "is_quote_status": false,
    "lang": "en",
    "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
    },
    "place": null,
    "possibly_sensitive": false,
    "retweet_count": 2,
    "retweeted": false,
    "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
    "text": "Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is",
    "truncated": true,
    "user": {
        "contributors_enabled": false,
        "created_at": "Tue Apr 07 19:49:08 +0000 2009",
        "default_profile": false,
        "default_profile_image": false,
        "description": "Inquisitive free man who loves life. \nRT is not an endorsement.\nI love everyone. My tweets r meant to question my own understanding!",
        "entities": {
            "description": {
                "urls": []
            }
        },
        "favourites_count": 18421,
        "follow_request_sent": false,
        "followers_count": 1239,
        "following": false,
        "friends_count": 1651,
        "geo_enabled": false,
        "has_extended_profile": false,
        "id": 29526123,
        "id_str": "29526123",
        "is_translation_enabled": false,
        "is_translator": false,
        "lang": "en",
        "listed_count": 17,
        "location": "white plains, NY",
        "name": "Siva #swachhbharat",
        "notifications": false,
        "profile_background_color": "BADFCD",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_tile": false,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/29526123/1513447624",
        "profile_image_url": "http://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_link_color": "FF0000",
        "profile_sidebar_border_color": "F2E195",
        "profile_sidebar_fill_color": "FFF7CC",
        "profile_text_color": "0C3E53",
        "profile_use_background_image": true,
        "protected": false,
        "screen_name": "muthushiv",
        "statuses_count": 22905,
        "time_zone": "Europe/London",
        "translator_type": "none",
        "url": null,
        "utc_offset": 0,
        "verified": false
    }
},
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"text": "RT @muthushiv: Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is not a re\u2026",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Fri Jan 01 13:41:09 +0000 2016",
    "default_profile": true,
    "default_profile_image": false,
    "description": "A Science Enthusiast. RTs not an Endorsement.",
    "entities": {
        "description": {
            "urls": []
        }
    },
    "favourites_count": 9395,
    "follow_request_sent": false,
    "followers_count": 596,
    "following": false,
    "friends_count": 196,
    "geo_enabled": false,
    "has_extended_profile": false,
    "id": 4689495258,
    "id_str": "4689495258",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "en",
    "listed_count": 23,
    "location": "",
    "name": "\u0b86\u0ba9\u0bcd\u0bae\u0bc0\u0b95 \u0b85\u0bb0\u0b9a\u0bbf\u0baf\u0bb2\u0bcd\ud83c\uddee\ud83c\uddf3",
    "notifications": false,
    "profile_background_color": "F5F8FA",
    "profile_background_image_url": null,
    "profile_background_image_url_https": null,
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/928671220698038272/L6_sJ8KH_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "Mr_Mannagatti",
    "statuses_count": 27802,
    "time_zone": "Stockholm",
    "translator_type": "none",
    "url": null,
    "utc_offset": 3600,
    "verified": false
}},{
"contributors": null,
"coordinates": null,
"created_at": "Tue Jan 30 14:01:19 +0000 2018",
"entities": {
    "hashtags": [],
    "symbols": [],
    "urls": [],
    "user_mentions": [
        {
            "id": 29526123,
            "id_str": "29526123",
            "indices": [
                3,
                13
            ],
            "name": "Siva #swachhbharat",
            "screen_name": "muthushiv"
        }
    ]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 958339345219436544,
"id_str": "958339345219436544",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"place": null,
"retweet_count": 2,
"retweeted": false,
"retweeted_status": {
    "contributors": null,
    "coordinates": null,
    "created_at": "Tue Jan 30 13:56:22 +0000 2018",
    "entities": {
        "hashtags": [],
        "symbols": [],
        "urls": [
            {
                "display_url": "twitter.com/i/web/status/9\u2026",
                "expanded_url": "https://twitter.com/i/web/status/958338098605080577",
                "indices": [
                    117,
                    140
                ],
                "url": ""
            }
        ],
        "user_mentions": []
    },
    "favorite_count": 2,
    "favorited": false,
    "geo": null,
    "id": 958338098605080577,
    "id_str": "958338098605080577",
    "in_reply_to_screen_name": null,
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "is_quote_status": false,
    "lang": "en",
    "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
    },
    "place": null,
    "possibly_sensitive": false,
    "retweet_count": 2,
    "retweeted": false,
    "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
    "text": "Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is",
    "truncated": true,
    "user": {
        "contributors_enabled": false,
        "created_at": "Tue Apr 07 19:49:08 +0000 2009",
        "default_profile": false,
        "default_profile_image": false,
        "description": "Inquisitive free man who loves life. \nRT is not an endorsement.\nI love everyone. My tweets r meant to question my own understanding!",
        "entities": {
            "description": {
                "urls": []
            }
        },
        "favourites_count": 18421,
        "follow_request_sent": false,
        "followers_count": 1239,
        "following": false,
        "friends_count": 1651,
        "geo_enabled": false,
        "has_extended_profile": false,
        "id": 29526123,
        "id_str": "29526123",
        "is_translation_enabled": false,
        "is_translator": false,
        "lang": "en",
        "listed_count": 17,
        "location": "white plains, NY",
        "name": "Siva #swachhbharat",
        "notifications": false,
        "profile_background_color": "BADFCD",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme12/bg.gif",
        "profile_background_tile": false,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/29526123/1513447624",
        "profile_image_url": "http://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/942508100652814336/XAhEbLOf_normal.jpg",
        "profile_link_color": "FF0000",
        "profile_sidebar_border_color": "F2E195",
        "profile_sidebar_fill_color": "FFF7CC",
        "profile_text_color": "0C3E53",
        "profile_use_background_image": true,
        "protected": false,
        "screen_name": "muthushiv",
        "statuses_count": 22905,
        "time_zone": "Europe/London",
        "translator_type": "none",
        "url": null,
        "utc_offset": 0,
        "verified": false
    }
},
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"text": "RT @muthushiv: Best way to erase a religion is by calling it a \"Heritage\". Jallikattu is not a religion, but a Heritage. Pongal is not a ",
"truncated": false,
"user": {
    "contributors_enabled": false,
    "created_at": "Wed Jul 08 05:02:36 +0000 2009",
    "default_profile": true,
    "default_profile_image": false,
    "description": "For the protection of the righteous, for the destruction of wicked, and for the establishment of Dharma, I am born in every age. \u0b95\u0bbf\u0bb0\u0bc1\u0bb7\u0bcd\u0ba3\u0bbe\u0bb0\u0bcd\u0baa\u0bcd\u0baa\u0ba3\u0bae\u0bcd.",
    "entities": {
        "description": {
            "urls": []
        }
    },
    "favourites_count": 3633,
    "follow_request_sent": false,
    "followers_count": 79,
    "following": false,
    "friends_count": 138,
    "geo_enabled": false,
    "has_extended_profile": false,
    "id": 54804923,
    "id_str": "54804923",
    "is_translation_enabled": false,
    "is_translator": false,
    "lang": "en",
    "listed_count": 0,
    "location": "",
    "name": "Sai Sakthi",
    "notifications": false,
    "profile_background_color": "C0DEED",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/952740575924514816/ef9fWKQz_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/952740575924514816/ef9fWKQz_normal.jpg",
    "profile_link_color": "1DA1F2",
    "profile_sidebar_border_color": "C0DEED",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "protected": false,
    "screen_name": "RishyaShringar",
    "statuses_count": 1250,
    "time_zone": "New Delhi",
    "translator_type": "none",
    "url": null,
    "utc_offset": 19800,
    "verified": false
}}]}

您需要遍历列表以获取所需数据

示例:

import json
path = "Path_to.json"
values = json.load(open(path, 'r'))

for value in values['tweetdata']:
    print(value['retweeted_status']['text'])

<强>输出:

Best way to erase a religion is by calling it a "Heritage". Jallikattu is not a religion, but a Heritage. Pongal is
Best way to erase a religion is by calling it a "Heritage". Jallikattu is not a religion, but a Heritage. Pongal is