Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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文件的值_Python_Json - Fatal编程技术网

在Python中提取JSON文件的值

在Python中提取JSON文件的值,python,json,Python,Json,我已经研究了大约两天了,如何用Python在JSON文件中提取特定值。 我试图将JSON作为字典打开,但没有成功,控制台在显示为KeyError的地方出错。 以下是JSON文件: {"episodes": [{"episode_id": 0, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.6

我已经研究了大约两天了,如何用Python在JSON文件中提取特定值。 我试图将JSON作为字典打开,但没有成功,控制台在显示为KeyError的地方出错。 以下是JSON文件:

{"episodes": [{"episode_id": 0, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.69643, 0.15825, -2.90618], "start_rotation": [0, 0.91930, 0, -0.39357], "info": {"geodesic_distance": 10.84175}, "goals": [{"position": [-13.14364, 0.15825, -5.08375], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 1, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.27251, 0.15825, -1.17589], "start_rotation": [0, 0.95258, 0, -0.30428], "info": {"geodesic_distance": 12.50322}, "goals": [{"position": [-11.20059, 0.15825, -4.13390], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 2, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.92178, 0.15825, -0.08615], "start_rotation": [0, 0.99905, 0, -0.04347], "info": {"geodesic_distance": 13.12434}, "goals": [{"position": [1.15770, 0.15825, -2.05222], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 3, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.23818, 0.15825, -0.02986], "start_rotation": [0, 0.76583, 0, -0.64305], "info": {"geodesic_distance": 9.30301}, "goals": [{"position": [0.28725, 0.15825, -1.28491], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 4, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.53066, 0.15825, -3.34582], "start_rotation": [0, 0.99568, 0, 0.09288], "info": {"geodesic_distance": 6.14450}, "goals": [{"position": [-10.87447, 0.15825, -4.42080], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 5, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.31268, 0.15825, 0.33677], "start_rotation": [0, 0.01113, 0, -0.99994], "info": {"geodesic_distance": 11.97798}, "goals": [{"position": [0.01400, 0.15825, -5.10602], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 6, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-5.93276, 0.15825, -5.05172], "start_rotation": [0, 0.80199, 0, -0.59733], "info": {"geodesic_distance": 8.53580}, "goals": [{"position": [-11.05243, 0.15825, -4.40370], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 7, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.84554, 0.15825, -1.93460], "start_rotation": [0, 0.60593, 0, -0.79552], "info": {"geodesic_distance": 12.75864}, "goals": [{"position": [-0.03729, 0.15825, -3.33406], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 8, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.29683, 0.15825, -1.60467], "start_rotation": [0, 0.76842, 0, -0.63995], "info": {"geodesic_distance": 2.57728}, "goals": [{"position": [-4.20521, 0.15825, -3.56520], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 9, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.91753, 0.15825, -5.28619], "start_rotation": [0, 0.52758, 0, -0.84951], "info": {"geodesic_distance": 8.25284}, "goals": [{"position": [-1.89879, 0.15825, -0.96901], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 10, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.02954, 0.15825, 0.51230], "start_rotation": [0, 0.68510, 0, -0.72845], "info": {"geodesic_distance": 9.27165}, "goals": [{"position": [-8.02032, 0.15825, -1.51654], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 11, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.49941, 0.15825, -2.84699], "start_rotation": [0, 0.99949, 0, -0.03193], "info": {"geodesic_distance": 4.97891}, "goals": [{"position": [-7.26894, 0.15825, -4.38928], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 12, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-13.12113, 0.15825, -2.01151], "start_rotation": [0, 0.00147, 0, 1.00000], "info": {"geodesic_distance": 4.01653}, "goals": [{"position": [-11.70544, 0.15825, -4.88971], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 13, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.99597, 0.15825, -0.52274], "start_rotation": [0, 0.70819, 0, -0.70602], "info": {"geodesic_distance": 13.18624}, "goals": [{"position": [-0.69856, 0.15825, 0.83643], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 14, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-11.43938, 0.15825, -3.45317], "start_rotation": [0, 0.50339, 0, -0.86406], "info": {"geodesic_distance": 4.03508}, "goals": [{"position": [-8.19167, 0.15825, -1.93181], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 15, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.72207, 0.15825, -4.47676], "start_rotation": [0, 0.90272, 0, 0.43022], "info": {"geodesic_distance": 6.46454}, "goals": [{"position": [-0.38587, 0.15825, -1.12072], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 16, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-6.09235, 0.15825, -2.18900], "start_rotation": [0, 0.96351, 0, 0.26769], "info": {"geodesic_distance": 4.34329}, "goals": [{"position": [-5.67817, 0.15825, 0.27397], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 17, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.95254, 0.15825, -1.81387], "start_rotation": [0, 0.67728, 0, -0.73573], "info": {"geodesic_distance": 10.23247}, "goals": [{"position": [-0.53492, 0.15825, -3.89919], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 18, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-2.45771, 0.15825, -1.11409], "start_rotation": [0, 0.87280, 0, -0.48808], "info": {"geodesic_distance": 9.78061}, "goals": [{"position": [-11.06771, 0.15825, -2.44379], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 19, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.42903, 0.15825, -5.04500], "start_rotation": [0, 0.93468, 0, -0.35549], "info": {"geodesic_distance": 12.36648}, "goals": [{"position": [-13.54984, 0.15825, -0.48622], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 20, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.18521, 0.15825, -3.74834], "start_rotation": [0, 0.44779, 0, 0.89414], "info": {"geodesic_distance": 14.85184}, "goals": [{"position": [-10.82548, 0.15825, 0.70285], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 21, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.85515, 0.15825, -2.98223], "start_rotation": [0, 0.09338, 0, -0.99563], "info": {"geodesic_distance": 6.68912}, "goals": [{"position": [-6.16232, 0.15825, -5.20815], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 22, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-6.27376, 0.15825, -2.23706], "start_rotation": [0, 0.99001, 0, -0.14099], "info": {"geodesic_distance": 3.79830}, "goals": [{"position": [-6.19482, 0.15825, -4.96746], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 23, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.16077, 0.15825, -1.60802], "start_rotation": [0, 0.94548, 0, -0.32567], "info": {"geodesic_distance": 12.27123}, "goals": [{"position": [-10.64299, 0.15825, 0.50452], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 24, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.31097, 0.15825, -4.75103], "start_rotation": [0, 0.89844, 0, 0.43909], "info": {"geodesic_distance": 2.69302}, "goals": [{"position": [-10.97003, 0.15825, -2.87049], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 25, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-5.46296, 0.15825, -1.54872], "start_rotation": [0, 0.99997, 0, -0.00729], "info": {"geodesic_distance": 6.33168}, "goals": [{"position": [-10.97181, 0.29593, -0.02616], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 26, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.07279, 0.15825, -5.10577], "start_rotation": [0, 0.14801, 0, -0.98899], "info": {"geodesic_distance": 14.67512}, "goals": [{"position": [-11.26352, 0.15825, -4.54955], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 27, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.79529, 0.15825, -1.82792], "start_rotation": [0, 0.19934, 0, -0.97993], "info": {"geodesic_distance": 8.34021}, "goals": [{"position": [-7.62291, 0.15825, 0.12312], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 28, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-8.41349, 0.15825, -1.25847], "start_rotation": [0, 0.14021, 0, 0.99012], "info": {"geodesic_distance": 11.85034}, "goals": [{"position": [0.61265, 0.15825, -3.20424], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 29, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.75539, 0.15825, 0.76826], "start_rotation": [0, 0.22594, 0, 0.97414], "info": {"geodesic_distance": 12.30805}, "goals": [{"position": [-2.40936, 0.15825, -1.97508], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 30, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.21566, 0.15825, -1.58291], "start_rotation": [0, 0.18906, 0, 0.98197], "info": {"geodesic_distance": 11.24596}, "goals": [{"position": [-12.60168, 0.15825, 0.52849], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 31, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.86631, 0.15825, -4.50171], "start_rotation": [0, 0.61109, 0, 0.79156], "info": {"geodesic_distance": 10.86217}, "goals": [{"position": [-13.31573, 0.15825, -2.42068], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 32, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.57674, 0.15825, -2.19489], "start_rotation": [0, 0.95221, 0, 0.30546], "info": {"geodesic_distance": 8.92206}, "goals": [{"position": [-7.36777, 0.15825, -0.66295], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 33, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-9.54422, 0.15825, -5.56967], "start_rotation": [0, 0.66227, 0, -0.74926], "info": {"geodesic_distance": 13.24524}, "goals": [{"position": [-0.45499, 0.15825, -4.55594], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 34, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.94664, 0.15825, -4.36129], "start_rotation": [0, 0.96210, 0, -0.27269], "info": {"geodesic_distance": 8.29345}, "goals": [{"position": [0.62556, 0.15825, 0.62093], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 35, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.62107, 0.15825, -4.67582], "start_rotation": [0, 0.99249, 0, -0.12229], "info": {"geodesic_distance": 10.64388}, "goals": [{"position": [0.10460, 0.15825, -1.65684], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 36, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-13.14231, 0.15825, -0.38757], "start_rotation": [0, 0.80309, 0, 0.59586], "info": {"geodesic_distance": 15.32506}, "goals": [{"position": [0.26247, 0.15825, 0.68985], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 37, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-6.42330, 0.15825, -0.23259], "start_rotation": [0, 0.37051, 0, -0.92883], "info": {"geodesic_distance": 6.03755}, "goals": [{"position": [-10.45571, 0.15825, 0.73628], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 38, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-9.64053, 0.15825, 1.06549], "start_rotation": [0, 0.99596, 0, -0.08981], "info": {"geodesic_distance": 6.10194}, "goals": [{"position": [-13.36366, 0.15825, -1.72965], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 39, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.68516, 0.15825, -5.35013], "start_rotation": [0, 0.95838, 0, -0.28549], "info": {"geodesic_distance": 6.94723}, "goals": [{"position": [-0.63791, 0.15825, -1.99644], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 40, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.76313, 0.15825, -4.75415], "start_rotation": [0, 0.15798, 0, 0.98744], "info": {"geodesic_distance": 11.59740}, "goals": [{"position": [-9.02077, 0.15825, -1.24652], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 41, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-13.21179, 0.15825, 0.53253], "start_rotation": [0, 0.85921, 0, 0.51162], "info": {"geodesic_distance": 17.54941}, "goals": [{"position": [-0.02380, 0.15825, -3.32647], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 42, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.82166, 0.15825, -4.96479], "start_rotation": [0, 0.85270, 0, -0.52239], "info": {"geodesic_distance": 14.47196}, "goals": [{"position": [-0.78955, 0.15825, -0.65403], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 43, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.04631, 0.15825, -2.46995], "start_rotation": [0, 0.20081, 0, -0.97963], "info": {"geodesic_distance": 4.11173}, "goals": [{"position": [-12.98902, 0.15825, -5.18417], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 44, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-8.89584, 0.15825, -1.15666], "start_rotation": [0, 0.13640, 0, 0.99065], "info": {"geodesic_distance": 9.52208}, "goals": [{"position": [-0.33881, 0.15825, -0.10487], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 45, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.06920, 0.15825, 0.99804], "start_rotation": [0, 0.40344, 0, -0.91501], "info": {"geodesic_distance": 10.50958}, "goals": [{"position": [-8.70199, 0.15825, -1.14633], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 46, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-2.48506, 0.15825, -1.72918], "start_rotation": [0, 0.17466, 0, 0.98463], "info": {"geodesic_distance": 8.93987}, "goals": [{"position": [-0.37711, 0.15825, -3.80068], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 47, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.97148, 0.15825, 0.75385], "start_rotation": [0, 0.60695, 0, 0.79474], "info": {"geodesic_distance": 9.97725}, "goals": [{"position": [-5.01518, 0.15825, -0.42516], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 48, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.15981, 0.15825, -0.08897], "start_rotation": [0, 0.91645, 0, 0.40015], "info": {"geodesic_distance": 8.71885}, "goals": [{"position": [-7.39338, 0.15825, -1.12181], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 49, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.66221, 0.15825, -4.03617], "start_rotation": [0, 0.83346, 0, -0.55259], "info": {"geodesic_distance": 9.61219}, "goals": [{"position": [-12.55914, 0.15825, -2.19559], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 50, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-11.51218, 0.15825, -2.83646], "start_rotation": [0, 0.81465, 0, -0.57996], "info": {"geodesic_distance": 12.84149}, "goals": [{"position": [-0.67053, 0.15825, -5.22697], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 51, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.67115, 0.15825, -5.10748], "start_rotation": [0, 0.39516, 0, 0.91861], "info": {"geodesic_distance": 12.88859}, "goals": [{"position": [-4.15966, 0.15825, 0.43623], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 52, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.39793, 0.15825, -4.34703], "start_rotation": [0, 0.98072, 0, -0.19544], "info": {"geodesic_distance": 12.46506}, "goals": [{"position": [-6.07942, 0.15825, -4.90514], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 53, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.91724, 0.15825, -2.09274], "start_rotation": [0, 0.69861, 0, -0.71550], "info": {"geodesic_distance": 5.67111}, "goals": [{"position": [-4.22504, 0.15825, -4.73827], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 54, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [0.15980, 0.15825, -1.01231], "start_rotation": [0, 0.96185, 0, 0.27358], "info": {"geodesic_distance": 14.02399}, "goals": [{"position": [-11.42104, 0.15825, -5.17564], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 55, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-1.99057, 0.15825, -5.19112], "start_rotation": [0, 0.98848, 0, 0.15133], "info": {"geodesic_distance": 14.37388}, "goals": [{"position": [-13.41880, 0.15825, 0.54180], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 56, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-0.43707, 0.15825, -4.36404], "start_rotation": [0, 0.65389, 0, -0.75659], "info": {"geodesic_distance": 12.16318}, "goals": [{"position": [-9.03490, 0.15825, -4.41518], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 57, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-4.56474, 0.15825, -3.73403], "start_rotation": [0, 0.99608, 0, -0.08850], "info": {"geodesic_distance": 10.90659}, "goals": [{"position": [-12.37831, 0.15825, -4.95079], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 58, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.44619, 0.15825, 0.55436], "start_rotation": [0, 0.99505, 0, 0.09938], "info": {"geodesic_distance": 9.54619}, "goals": [{"position": [0.00265, 0.15825, -1.79228], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 59, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.28140, 0.15825, -5.14845], "start_rotation": [0, 0.20258, 0, 0.97927], "info": {"geodesic_distance": 10.70645}, "goals": [{"position": [-10.18044, 0.15825, 0.54752], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 60, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-7.45234, 0.15825, -0.41374], "start_rotation": [0, 0.32170, 0, 0.94684], "info": {"geodesic_distance": 5.71997}, "goals": [{"position": [-4.93141, 0.15825, -4.12972], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 61, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-9.36816, 0.15825, -5.07130], "start_rotation": [0, 0.46023, 0, 0.88780], "info": {"geodesic_distance": 9.76535}, "goals": [{"position": [-3.75120, 0.15825, -5.55128], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 62, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-10.76006, 0.15825, -3.86923], "start_rotation": [0, 0.58676, 0, 0.80976], "info": {"geodesic_distance": 6.96793}, "goals": [{"position": [-5.69414, 0.15825, -0.49670], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 63, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.67572, 0.15825, -0.40527], "start_rotation": [0, 0.90011, 0, 0.43567], "info": {"geodesic_distance": 3.17985}, "goals": [{"position": [-10.65360, 0.15825, -1.29946], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 64, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-1.84010, 0.15825, -0.28997], "start_rotation": [0, 0.06734, 0, -0.99773], "info": {"geodesic_distance": 12.87526}, "goals": [{"position": [-11.94510, 0.15825, -4.88166], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 65, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.94408, 0.15825, 0.44463], "start_rotation": [0, 0.93589, 0, -0.35228], "info": {"geodesic_distance": 5.53046}, "goals": [{"position": [-8.92847, 0.15825, -1.47914], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 66, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-9.70954, 0.15825, 0.84011], "start_rotation": [0, 0.95211, 0, 0.30575], "info": {"geodesic_distance": 12.00260}, "goals": [{"position": [0.45035, 0.15825, -0.69834], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 67, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.96797, 0.15825, -3.57856], "start_rotation": [0, 0.95923, 0, -0.28261], "info": {"geodesic_distance": 10.56293}, "goals": [{"position": [-10.78041, 0.15825, -5.28849], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 68, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-3.20631, 0.15825, -4.69077], "start_rotation": [0, 0.60025, 0, 0.79982], "info": {"geodesic_distance": 4.86395}, "goals": [{"position": [-6.72126, 0.15825, -1.96469], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 69, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-12.91250, 0.15825, -1.11815], "start_rotation": [0, 0.68527, 0, 0.72829], "info": {"geodesic_distance": 8.54307}, "goals": [{"position": [-6.28522, 0.15825, -5.11800], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 70, "scene_id": "data/scene_datasets/gibson/Cantwell.glb", "start_position": [-2.96933, 0.15825, -5.27783], "start_rotation": [0, 0.74645, 0, 0.66545], "info": {"geodesic_distance": 7.68400}, "goals": [{"position": [-0.69375, 0.15825, -0.66339], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 71, "scene_id": "data/scene_datasets/gibson/Denmark.glb", "start_position": [-2.73576, 0.16989, 1.98005], "start_rotation": [0, 0.84860, 0, -0.52904], "info": {"geodesic_distance": 4.69387}, "goals": [{"position": [0.45165, 0.16989, -0.35319], "radius": null}], "shortest_paths": null, "start_room": null}, {"episode_id": 72, "scene_id": "data/scene_datasets/gibson/Denmark.glb", "start_position": [-0.05506, 0.16989, -0.76517], "start_rotation": [0, 0.92620, 0, -0.37704], "info": {"geodesic_distance": 3.47826}, "goals": [{"position": [1.29681, 0.16989, 2.05960], "radius": null}], "shortest_paths": null, "start_room": null}}
(删除了很多行,以不超过帖子的字符限制) 这是我试图使用的代码,我怀疑我需要深入“剧集”来访问我想要的值(场景id)


提前感谢您的帮助。

您的代码与数据不匹配

在数据中,在顶层,您有一个带有一个键的字典,“剧集”

当您对数据中的i执行
操作时,它将通过一次循环,将
i
设置为“剧集”。这可能不是你想要的

您可能想要的是:

for episode in data['episodes']:
    print(episode['scene_id'])


更一般地说,看看这篇文章或类似文章;调试程序(您或其他人的)是一项非常有价值的技能。

数据中没有键
'scene\u id'
。看看这个结构。您有一本带有键
的词典,该键是“剧集”
。此键的值是一个列表。此列表包含字典,这些字典有一个键
'scene\u id'
。感谢您按照我现在想要的方式工作,感谢您的帮助和文章:)
for episode in data['episodes']:
    print(episode['scene_id'])