首页 > 解决方案 > 我无法追加/更新字典

问题描述

我不确定我在标题上写了正确的东西。

这是我使用的临时工具:

temp = [{'kind': 'youtube#commentThread', 'etag': 't0DC75yq28JLfapz2tE0vdFBPbI', 'id': 'UgwDh4nPhgkxFWgKugd4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'te5pWB4MXQOqSyIRLKRfoot3DBE', 'id': 'UgwDh4nPhgkxFWgKugd4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': '04:05 - Game 1\n18:40 - Game 2\n39:18 - Game 3\n.\n.\n.\n53:40 - Game 4', 'textOriginal': '04:05 - Game 1\n18:40 - Game 2\n39:18 - Game 3\n.\n.\n.\n53:40 - Game 4', 'authorDisplayName': 'Call of Duty League', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJxOw3lEOR4JJoANzP9SpvxwqbHQFLyKXbodJQ=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCbLIqv9Puhyp9_ZjVtfOy7w', 'authorChannelId': {'value': 'UCbLIqv9Puhyp9_ZjVtfOy7w'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 20, 'publishedAt': '2020-05-24T23:45:09Z', 'updatedAt': '2020-05-24T23:45:09Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'J6GD9jA9Feu_H5bqDekuqWYxuq8', 'id': 'Ugwlk-A0J6eEj0JX1_d4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'RTLyHxwu6TP3YEpK3uukxuVjvZc', 'id': 'Ugwlk-A0J6eEj0JX1_d4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': "", 'textOriginal': "", 'authorDisplayName': 'ed dupont', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJz7LbTnu9ijG0k9AT0PU8APaPwL6hA5agOvDQ=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC3bpzuvdQvVRqY2_qVK0YPQ', 'authorChannelId': {'value': 'UC3bpzuvdQvVRqY2_qVK0YPQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T08:30:39Z', 'updatedAt': '2020-05-25T08:31:27Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'KbLI1taGpBwa5N1eFTfdHkoEhU8', 'id': 'UgyOsNEsLi8-pyxDOCt4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'j_jIyr7uUZKw1igiFcYxSWH7RKo', 'id': 'UgyOsNEsLi8-pyxDOCt4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'See how far a non bitching teammate gets you? Gotta love Prestinni', 'textOriginal': 'See how far a non bitching teammate gets you? Gotta love Prestinni', 'authorDisplayName': 'Cirdec4', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzg3O6QDkn-MWF-y9ffkTIfYGWuD9ZVCAQJyQ=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC-ChyQTvh1slIK2qtLNdZMQ', 'authorChannelId': {'value': 'UC-ChyQTvh1slIK2qtLNdZMQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T05:46:36Z', 'updatedAt': '2020-05-25T05:46:36Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': '3CO13KdlL867XPDq--qkeCGwk8E', 'id': 'UgyzOZjkN_qCPt8anV54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'hd-hmzfEzI1Nx_tIRnLOZ8GEico', 'id': 'UgyzOZjkN_qCPt8anV54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': '"Nice shots from accuracy"......\nHuh, I sure hope so lol', 'textOriginal': '"Nice shots from accuracy"......\nHuh, I sure hope so lol', 'authorDisplayName': 'Chance Bates', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJxhpDZUST6nKyOeRPbD6poP5-iNRcOikpz2Dg=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCzfVbzNLZw8Inh-2LnA959w', 'authorChannelId': {'value': 'UCzfVbzNLZw8Inh-2LnA959w'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T05:32:58Z', 'updatedAt': '2020-05-25T05:32:58Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': '-UCfMvoReVh9D9aC2Q2eA2RfnO8', 'id': 'UgyIWBG8QznZUw3PU0x4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'w24T1f3XcSGWhrIEFxjx54lHfyc', 'id': 'UgyIWBG8QznZUw3PU0x4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': "", 'textOriginal': "", 'authorDisplayName': 'Jaymes Johnson', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzcgM94R0IkXuleHeIL6LbqDqazKuqfWpIv=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC8Fh--z_Cnb8EC2MwDoKefQ', 'authorChannelId': {'value': 'UC8Fh--z_Cnb8EC2MwDoKefQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T04:00:08Z', 'updatedAt': '2020-05-25T04:00:08Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, [{'kind': 'youtube#commentThread', 'etag': '0SjBlnSNrEnRcl3oFeyjGEndxkw', 'id': 'UgxKDSuoYfA0iYpRd-54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'waRfKBANuZEcnM3tKUJK8cxLX6Q', 'id': 'UgxKDSuoYfA0iYpRd-54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Preston really just ties the huntsmen together', 'textOriginal': 'Preston really just ties the huntsmen together', 'authorDisplayName': 'OKG Disbld', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJyF7M6h9c9u5izrIls7mFH5lDdVeD-bkTJJjg=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCXCn8VPxEK8yx5cn1GSXeVg', 'authorChannelId': {'value': 'UCXCn8VPxEK8yx5cn1GSXeVg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 2, 'publishedAt': '2020-05-25T03:54:23Z', 'updatedAt': '2020-05-25T03:54:23Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'hkgFxd4BtvECVN-R-9Ce_hDzcbY', 'id': 'UgzUS79dqvguTulmg4J4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'j9pEJB2lLa-eW5r9S-MfFWX08TA', 'id': 'UgzUS79dqvguTulmg4J4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'What gaming platform are they playing on?', 'textOriginal': 'What gaming platform are they playing on?', 'authorDisplayName': 'JAY P', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJyccqFTGKWWcUnRXfHtpx_Ukfbzgju-_i6pkA=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCrG7H4W_Ij1_E1sxD4Kf2WA', 'authorChannelId': {'value': 'UCrG7H4W_Ij1_E1sxD4Kf2WA'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T03:10:25Z', 'updatedAt': '2020-05-25T03:10:25Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 1, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'KhWbq9mJqY5MUQrvOe83IuCenqw', 'id': 'UgwtHBN2fhLenQb2kgB4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'BUM6Fvh0tCm1VgPkyis9KlVXcSw', 'id': 'UgwtHBN2fhLenQb2kgB4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Please have the stats up more then the faces when you go back and forth', 'textOriginal': 'Please have the stats up more then the faces when you go back and forth', 'authorDisplayName': 'jakemx4', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzptrmxOVLuB6vZj-zClGeJkBoRAOdfv8b27Q=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCVcM99AEcWAyQIMCb5nAPUg', 'authorChannelId': {'value': 'UCVcM99AEcWAyQIMCb5nAPUg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 1, 'publishedAt': '2020-05-25T01:49:12Z', 'updatedAt': '2020-05-25T01:49:12Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'Ovks4fvIQeHkahWKCe3VXbv59jY', 'id': 'UgxZwIudfutZ2o1LZnp4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': '0EvHJu2i77LFc2-oFbkq0GOhDyE', 'id': 'UgxZwIudfutZ2o1LZnp4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'That t.j Semtex part reminds me of that clip, "tell me when to throw my grenade battle buddy"', 'textOriginal': 'That t.j Semtex part reminds me of that clip, "tell me when to throw my grenade battle buddy"', 'authorDisplayName': 'Ryan Donnelly', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzKwvS5ntOGD-HFlg5cn-M9uHSUpHhw4BmWmw=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCe_OzfPnu-cO-2IlVNfB8VA', 'authorChannelId': {'value': 'UCe_OzfPnu-cO-2IlVNfB8VA'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 6, 'publishedAt': '2020-05-25T01:41:16Z', 'updatedAt': '2020-05-25T01:41:16Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'bgPxCBDvEBhkZ0farLvUck7ypKY', 'id': 'Ugx2YNnRr3dSSl1V2OV4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': '4PrNxpTj_9liHanxnd_crYouIxM', 'id': 'Ugx2YNnRr3dSSl1V2OV4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': '', 'authorDisplayName': 'maxamillion beckett', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJwedihMYkpiuerMyRU47p7Bfuu08ZlF5Haszw=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCBixB60sGhFwhcXC3nMLo9g', 'authorChannelId': {'value': 'UCBixB60sGhFwhcXC3nMLo9g'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 8, 'publishedAt': '2020-05-25T01:41:09Z', 'updatedAt': '2020-05-25T01:41:09Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}], [{'kind': 'youtube#commentThread', 'etag': 'ya1ezB7Bgt2BiyBe2CY2lufi8BI', 'id': 'UgzvKcfbwGqb2mIWGhl4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'EpFQIF1cIW6ARE7eyPtTY1tbFro', 'id': 'UgzvKcfbwGqb2mIWGhl4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': "", 'authorDisplayName': 'Kaoukabi Jaouad', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzpCZCHBPukYMlwd_1xw9_DvHULCFFErVndxg=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC43P7a8ZyWf-gHwfAOK1Ybg', 'authorChannelId': {'value': 'UC43P7a8ZyWf-gHwfAOK1Ybg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 3, 'publishedAt': '2020-05-25T01:30:31Z', 'updatedAt': '2020-05-25T01:30:31Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'P0OqQdqil06ajanxEPSmRSfGV6M', 'id': 'Ugz-KXSab012wx7xx0F4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': '4ixLRKJ1-hUetfdZ_oXtdST6luI', 'id': 'Ugz-KXSab012wx7xx0F4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'The twins are feasting....ya love to see it.', 'textOriginal': 'The twins are feasting....ya love to see it.', 'authorDisplayName': 'Sean Cunningham', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJwIJTzeM0YKTMoFmHarpx-cSyxuVX1sBmQteA=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCF0N_9d0oaifOyRmTXZClqg', 'authorChannelId': {'value': 'UCF0N_9d0oaifOyRmTXZClqg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 6, 'publishedAt': '2020-05-25T01:13:02Z', 'updatedAt': '2020-05-25T01:13:02Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': '_7_zMHscyU5G_DdxZjlGJRv3p0A', 'id': 'UgylQ9a3Ghq8lWLZK5V4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': '85bermA0rZo0pyjZrKHh-hSW1LU', 'id': 'UgylQ9a3Ghq8lWLZK5V4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Damn, no one gave the huntsman a run for their money..\n Easiest dub!', 'textOriginal': 'Damn, no one gave the huntsman a run for their money..\n Easiest dub!', 'authorDisplayName': 'Tobias Ketteringham', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJznscJta-DmM-wai5HHBAjBWRur_ZoKsSUWww=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCHnkun4alZxMCGR-DAiIrTg', 'authorChannelId': {'value': 'UCHnkun4alZxMCGR-DAiIrTg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 3, 'publishedAt': '2020-05-25T01:11:04Z', 'updatedAt': '2020-05-25T01:11:04Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'J34nt0dUrjLsBx7sNz51SLwPenU', 'id': 'UgzKy1V9nFdM93w2hj54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'mbkQVDODSx1yb2EcvBV6G0t_61U', 'id': 'UgzKy1V9nFdM93w2hj54AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'How many times have sl lost in semis\n\nAnd NYXL is doing the same\n\n\nI FUCKING HATE THIS NY CURSE', 'textOriginal': 'How many times have sl lost in semis\n\nAnd NYXL is doing the same\n\n\nI FUCKING HATE THIS NY CURSE', 'authorDisplayName': 'Matteo Molina', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJwhUR91Y9omLqKfVkYgPsdjNaRbeYrQgPDqUg=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCSFbcitJBj6LxAMXFs8LaXQ', 'authorChannelId': {'value': 'UCSFbcitJBj6LxAMXFs8LaXQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T01:05:30Z', 'updatedAt': '2020-05-25T01:05:30Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'LlBj2zE6kPIXfQJd-UfN7qsY-QE', 'id': 'UgzoNFmOtfzcsmRVred4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'uCXPI0gNSEL-Nrfr3CnwhO6xvuY', 'id': 'UgzoNFmOtfzcsmRVred4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'you don’t even need to listen to Scump shout “let’s go BABY”  you know he’s saying that after a 1v2', 'textOriginal': 'you don’t even need to listen to Scump shout “let’s go BABY”  you know he’s saying that after a 1v2', 'authorDisplayName': 'Reece Malone', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJzeHsFx6Xdfk434EppSRNmCzFn84TW4Zp_sKg=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC1GzmmFIL_5s-p1DRzEQv1g', 'authorChannelId': {'value': 'UC1GzmmFIL_5s-p1DRzEQv1g'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 33, 'publishedAt': '2020-05-25T01:04:02Z', 'updatedAt': '2020-05-25T01:04:02Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}], [{'kind': 'youtube#commentThread', 'etag': 'vbamHwwqWwkSsqut084SrRtNMDM', 'id': 'UgxL-3kDqIv1epnS4PB4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'gDuu4sF87r78cdVwo2zLhm6yjDM', 'id': 'UgxL-3kDqIv1epnS4PB4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Prestinni literally makes huntsmen SND better without a question ', 'textOriginal': 'Prestinni literally makes huntsmen SND better without a question ', 'authorDisplayName': 'Tommy -_-', 'authorProfileImageUrl': '', 'authorChannelUrl': 'http://www.youtube.com/channel/UCeMNWF-9HCyWivL20cELCjg', 'authorChannelId': {'value': 'UCeMNWF-9HCyWivL20cELCjg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 32, 'publishedAt': '2020-05-25T00:59:06Z', 'updatedAt': '2020-05-25T00:59:06Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 4, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'So4LRmQs6vetg4JTvZHRv2elcrU', 'id': 'Ugy6tjmKfv0WxVTGSTN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'x4mizZXasOOb4Y7aGP9DpGeWt38', 'id': 'Ugy6tjmKfv0WxVTGSTN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Go scump', 'textOriginal': 'Go scump', 'authorDisplayName': 'DEMONIK COPWATCH', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJxrz7k1lRERS51Ch5Wb9BvNQuzN4TeD0eSH6Q=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCVBUGDhfAfmIn6BGpp9SWCw', 'authorChannelId': {'value': 'UCVBUGDhfAfmIn6BGpp9SWCw'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 1, 'publishedAt': '2020-05-25T00:55:11Z', 'updatedAt': '2020-05-25T00:55:11Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'lNjEYKV4sFu7Hzn4wVZZjk5PPgo', 'id': 'UgyWRoXYwI_a2hSvSFp4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'D1Hh26W2CGc9Iy7Dp7tJqDJDDvg', 'id': 'UgyWRoXYwI_a2hSvSFp4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'The fact that chicago are breaking hardpoint and stealing spawns are something we havent really seen', 'textOriginal': 'The fact that chicago are breaking hardpoint and stealing spawns are something we havent really seen', 'authorDisplayName': 'Tommy -_-', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJyR0lU2d8eM6MjC5P_1PN7E8dytCIYQaCuuDw=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCeMNWF-9HCyWivL20cELCjg', 'authorChannelId': {'value': 'UCeMNWF-9HCyWivL20cELCjg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 17, 'publishedAt': '2020-05-25T00:40:25Z', 'updatedAt': '2020-05-25T00:40:25Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'bAwMFPz0dv9f5oTFZHEsyaTFIjE', 'id': 'UgxE0CdDB4CZYBJ3XIN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'Gw5TAAPOxJO7E_hshbYHDwIT6rU', 'id': 'UgxE0CdDB4CZYBJ3XIN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'King scump is back, playing warzone is really improving his tactical instincts and making him an overall better player again', 'textOriginal': 'King scump is back, playing warzone is really improving his tactical instincts and making him an overall better player again', 'authorDisplayName': 'Barbarian My last stand', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJxHB49JfKFbRtZvDTrXPJZKv3xhxWPeNXxEKA=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCj8RN6oIfJ8uxO2pLqu2ZkQ', 'authorChannelId': {'value': 'UCj8RN6oIfJ8uxO2pLqu2ZkQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 2, 'publishedAt': '2020-05-25T00:38:55Z', 'updatedAt': '2020-05-25T00:38:55Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 1, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'jkoiPGVOyi5_xM23k3GydRdNRbY', 'id': 'UgwAhtZIv3n4oG9e7jx4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'lwoMJ61jUWGYNHSkmaBRUEzXN54', 'id': 'UgwAhtZIv3n4oG9e7jx4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Damn man. Focus and regain Kings.  We’ll get that dub next time.  One better hold and one better rotation in both hardpoints and we’d have won this 3-1.  Kill em next time NYSL!!!!', 'textOriginal': '', 'authorDisplayName': 'GO1 JR', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJwQ8aNGhc9YDLruVsKiOfs821_uShxlJUtP7Q=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCX3u88Zsgeu2L8bfvUisS0A', 'authorChannelId': {'value': 'UCX3u88Zsgeu2L8bfvUisS0A'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 3, 'publishedAt': '2020-05-25T00:31:05Z', 'updatedAt': '2020-05-25T00:31:05Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 16, 'isPublic': True}}], [{'kind': 'youtube#commentThread', 'etag': 'Uki5Ts3n6CUMAXJqWlU3hQHqhNc', 'id': 'UgyMqmldokGVzXq_Weh4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'K9cvb8m4WO4Y0CY6T7LNeL6yBvs', 'id': 'UgyMqmldokGVzXq_Weh4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'Chicago back on top :)', 'textOriginal': 'Chicago back on top :)', 'authorDisplayName': 'Hanna Naegeli', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJxG26RmChtOcYeD4tDquHM7CyZaaAyRgYXGNw=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UC_ILDK47TpBrnpgR5iTQYwA', 'authorChannelId': {'value': 'UC_ILDK47TpBrnpgR5iTQYwA'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 2, 'publishedAt': '2020-05-25T00:27:38Z', 'updatedAt': '2020-05-25T00:27:38Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'tuWgdEZUAhMI7QyIRHo2WRySQ8M', 'id': 'UgwV1lbd4r0vKvw_XU94AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'SWE3PhY7eeBbnS3sDMQkHpwAXVQ', 'id': 'UgwV1lbd4r0vKvw_XU94AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'loved it', 'textOriginal': 'loved it', 'authorDisplayName': 'Koral', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJyjJG1lpphfMILHelRnq7bnoHFJq2YcXOya_g=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCU7_5GsKckyoxLDiGm4k5vQ', 'authorChannelId': {'value': 'UCU7_5GsKckyoxLDiGm4k5vQ'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 0, 'publishedAt': '2020-05-25T00:24:26Z', 'updatedAt': '2020-05-25T00:24:26Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'yeFtCjrTo2mo_jTlBSOkObwMpVk', 'id': 'Ugwk2R6gpC3dVuD465Z4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'rVRFlxORoyl4p-qfkT_roUhlpDI', 'id': 'Ugwk2R6gpC3dVuD465Z4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': "Crazy how much better Chicago's hardpoints look. They rotated to perfection.", 'textOriginal': "Crazy how much better Chicago's hardpoints look. They rotated to perfection.", 'authorDisplayName': 'Sports Fan_91', 'authorProfileImageUrl': '', 'authorChannelUrl': 'http://www.youtube.com/channel/UCIhSBX9r0sbdgIFs2swBSgA', 'authorChannelId': {'value': 'UCIhSBX9r0sbdgIFs2swBSgA'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 30, 'publishedAt': '2020-05-25T00:23:37Z', 'updatedAt': '2020-05-25T00:23:37Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'T', 'video_channel': ''}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'AHdvjPclIe1t2E8RVaQrIBqFqsk', 'id': 'Ugw3YVPFxryr5_QqYGN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'VTXwExVzLW_5DNMcZJdNIzWV8Ds', 'id': 'Ugw3YVPFxryr5_QqYGN4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': 'I see lottie i watch', 'textOriginal': 'I see lottie i watch', 'authorDisplayName': 'My two bæs', 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJz4I9kOB8iYjsW5RE9LrNjctNT-sBfst3zCew=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCr-J-2AaViMgsVgeZLRtmpg', 'authorChannelId': {'value': 'UCr-J-2AaViMgsVgeZLRtmpg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 1, 'publishedAt': '2020-05-25T00:20:39Z', 'updatedAt': '2020-05-25T00:20:39Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': 'The eighth home series of the 2020 Call of Duty League season is live on May 22, 23, and 24 on YouTube Gaming. The Seattle Surge are virtually hosting the ...', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}, {'kind': 'youtube#commentThread', 'etag': 'y37zyvJLDL52UR6_RKcnz3SR2Yg', 'id': 'Ugw2aIG_Vq_ZsCdRTGx4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'topLevelComment': {'kind': 'youtube#comment', 'etag': 'j-NgPL49a8z_EezGyELuBOSj3_Q', 'id': 'Ugw2aIG_Vq_ZsCdRTGx4AaABAg', 'snippet': {'videoId': 'NRl-N8uByHY', 'textDisplay': '', 'textOriginal': '', 'authorDisplayName': "LET'S GO HUNTSMEN", 'authorProfileImageUrl': 'https://yt3.ggpht.com/a/AATXAJyucfyf78MT4_FnmOs3i-HP7hCG-DDTZFVCyQ=s48-c-k-c0xffffffff-no-rj-mo', 'authorChannelUrl': 'http://www.youtube.com/channel/UCi7CB0b-MAhl2l-rNIBqgDg', 'authorChannelId': {'value': 'UCi7CB0b-MAhl2l-rNIBqgDg'}, 'canRate': True, 'viewerRating': 'none', 'likeCount': 7, 'publishedAt': '2020-05-25T00:15:52Z', 'updatedAt': '2020-05-25T00:25:10Z', 'video_Title': 'Semi-Final B | New York Subliners vs Chicago Huntsmen | Seattle Surge Home Series | Day 3', 'video_desc': '', 'video_channel': 'Call of Duty League'}}, 'canReply': True, 'totalReplyCount': 0, 'isPublic': True}}]]

我尝试了这个并得到了没有错误的输出

z = []
z.append(temp[0]["snippet"])

所以看来我可以为此使用循环,所以我尝试了这个:

for x in range(len(temp)):
    z.append(temp[x]["snippet"])

for x in temp:
    z.append(x["snippet"])

我得到了一个错误:

TypeError: list indices must be integers or slices, not str

我不明白出了什么问题。除了循环部分之外,这两个代码似乎都是完全相同的代码。我浏览了嵌套字典,但找不到答案。

任何人都可以帮我区分吗?我的目标是提取每个元素的 ["snippet"]["topLevelComment"]["snippet"]。并用熊猫制作它的xlsx文件。正如你已经注意到的,我不熟悉字典。所以如果有什么好的方法可以提取这些东西,请赐教。

提前感谢您出色的顾问!

标签: jsonpython-3.xdictionary

解决方案


这个:

for x in temp:
    print(type(x))

产生这个

<class 'dict'>
<class 'dict'>
<class 'dict'>
<class 'dict'>
<class 'dict'>
<class 'list'>
<class 'list'>
<class 'list'>
<class 'list'>

所以看起来有些元素temp是字典,有些是列表。该错误来自尝试访问列表中x["snippet"]的那些元素。xtemp


推荐阅读