Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python脚本中提取json数据时出现KeyError用户名_Python - Fatal编程技术网

在python脚本中提取json数据时出现KeyError用户名

在python脚本中提取json数据时出现KeyError用户名,python,Python,{ “id”:553946, “url”:”http://www.tvmaze.com/episodes/553946/stranger-things-1x01-chapter-one-the-vanishing-of-will-byers", “名字”:“第一章:威尔·拜尔斯的消失”, “季节”:1, “数字”:1, “发布日期”:“2016-07-15”, “播放时间”:“, “空气夯实”:“2016-07-15T12:00:00+00:00”, “运行时间”:60, “评论”:[ { “用

{
“id”:553946,
“url”:”http://www.tvmaze.com/episodes/553946/stranger-things-1x01-chapter-one-the-vanishing-of-will-byers",
“名字”:“第一章:威尔·拜尔斯的消失”,
“季节”:1,
“数字”:1,
“发布日期”:“2016-07-15”,
“播放时间”:“,
“空气夯实”:“2016-07-15T12:00:00+00:00”,
“运行时间”:60,
“评论”:[
{
“用户名”:“Cloe”,
“投票”:
{
“有趣”:1,
“有用”:6,
“酷”:3
},
“文字”:“到目前为止,我最喜欢的一集!喜欢戏剧性的灯光和声音”,
“评级”:5,
“日期”:“2009-12-24”,
“_id”:{
$oid:“58b4394ed256330fdad6fa63”
}
}
],
“图像”:{
“中等”:http://static.tvmaze.com/uploads/images/medium_landscape/67/168918.jpg",
“原件”:http://static.tvmaze.com/uploads/images/original_untouched/67/168918.jpg"
},
《小结》:“一名小男孩神秘失踪,惊慌失措的母亲要求警方找到他。与此同时,男孩的朋友们进行了自己的搜索,并在森林中遇到了一名神秘女孩。”,
“_链接”:{
“自我”:{
“href”:”http://api.tvmaze.com/episodes/553946"
}
}

}
您在
评论[“\u id”]
作业的末尾有一个逗号?您确定数组中的每个元素都有一个“username”键吗?作业前请检查:
commission[“username”]=str(commission[“username”])如果commission中的“username”没有
。感谢您的回复!所以当我包含这个检查时,用户名的所有实例的值都返回为null,但是我100%地认为许多评论中都有用户名,有些超过1?