{u'contributors': None, u'truncated': False, u'text': u'@Kor3aYn @YouTube yeet', u'is_quote_status': False, u'in_reply_to_status_id': 805863281042878464L, u'id': 805864211544965122L, u'favorite_count': 0, u'source': u'<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>', u'retweeted': False, u'coordinates': None, u'timestamp_ms': u'1480967974922', u'entities': {u'user_mentions': [{u'id': 4249141216L, u'indices': [0, 8], u'id_str': u'4249141216', u'screen_name': u'Kor3aYn', u'name': u'YOUTUBE: Kor3aYn\U0001f1f0\U0001f1f7'}, {u'id': 10228272, u'indices': [9, 17], u'id_str': u'10228272', u'screen_name': u'YouTube', u'name': u'YouTube'}], u'symbols': [], u'hashtags': [], u'urls': []}, u'in_reply_to_screen_name': u'Kor3aYn', u'id_str': u'805864211544965122', u'display_text_range': [18, 22], u'retweet_count': 0, u'in_reply_to_user_id': 4249141216L, u'favorited': False, u'user': {u'follow_request_sent': None, u'profile_use_background_image': False, u'default_profile_image': False, u'id': 4858458939L, u'verified': False, u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/728320215986114560/f12oxR9J_normal.jpg', u'profile_sidebar_fill_color': u'000000', u'profile_text_color': u'000000', u'followers_count': 148, u'profile_sidebar_border_color': u'000000', u'id_str': u'4858458939', u'profile_background_color': u'000000', u'listed_count': 0, u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png', u'utc_offset': None, u'statuses_count': 76, u'description': None, u'friends_count': 21, u'location': u'Nuk3town', u'profile_link_color': u'ABB8C2', u'profile_image_url': u'http://pbs.twimg.com/profile_images/728320215986114560/f12oxR9J_normal.jpg', u'following': None, u'geo_enabled': False, u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/4858458939/1454015440', u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png', u'name': u'Smye', u'lang': u'en', u'profile_background_tile': False, u'favourites_count': 64, u'screen_name': u'i_Smye', u'notifications': None, u'url': None, u'created_at': u'Thu Jan 28 20:59:06 +0000 2016', u'contributors_enabled': False, u'time_zone': None, u'protected': False, u'default_profile': False, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': u'4249141216', u'lang': u'en', u'created_at': u'Mon Dec 05 19:59:34 +0000 2016', u'filter_level': u'low', u'in_reply_to_status_id_str': u'805863281042878464', u'place': None}
私は以下の配列をデコードされた配列として格納しています。私は2つのことである['id_str']を取得しようとしています。ツイートIDとユーザID。チェックのための辞書からのデータの抽出
if ScreenName not in decoded['user']['screen_name']: #if your name is not in the json
if decoded['id_str'][1] == Twitter_ID: # lets say 4858458939
これは私が持っているものであり、正しくはないことを理解しています。私は本質的に、2番目の 'str_id'の下に格納されているツイートの作者を取得しようとしていて、Twitter_ID変数に==をチェックしています。
どうすればいいか教えてください。 ありがとう
これはJSONと何が関係がありますか?与えられたデータはネイティブのPythonデータ構造です。*構文解析する前にJSONを*使用していればそれは疑問です。これはちょうど普通のPythonデータです。 –
タイトルを変更しました。ありがとうございます。 – smye
@smye配列ではありません(numpy配列です)。この構造はPythonの辞書です。 – rth