我试图从下面的 JSON 文件中提取“点”部分,但发生了错误:
with open("file1.json", "r") as read_file:
data = json.load(read_file)
data['points']
这是我的错误:
KeyError
Traceback (most recent call last)
<ipython-input-127-a97424859b31> in <module>()
----> 1 data['points']
KeyError: 'points'
这是我的 JSON:
{
"duration": 2727,
"height": 756,
"periods": [
{
"actions": [
{
"action": "createShape",
"actionID": 217,
"endTime": 2727,
"points": [
{
"t": 2014,
"x": 715,
"y": 367.5
},
{
"t": 2049,
"x": 714.5,
"y": 367.5
},
{
"t": 2064,
"x": 713.5,
"y": 367.5
},
{
"t": 2096,
"x": 711,
"y": 367.5
},
{
"t": 2115,
"x": 707.5,
"y": 368
},
{
"t": 2132,
"x": 705,
"y": 368
},
{
"t": 2148,
"x": 702,
"y": 368.5
},
{
"t": 2162,
"x": 700,
"y": 368.5
},
{
"t": 2176,
"x": 697,
"y": 369
},
{
"t": 2198,
"x": 693,
"y": 369
},
{
"t": 2215,
"x": 690,
"y": 369
},
{
"t": 2231,
"x": 686,
"y": 368.5
},
{
"t": 2248,
"x": 681,
"y": 368.5
},
{
"t": 2265,
"x": 676.5,
"y": 368.5
},
{
"t": 2276,
"x": 674.5,
"y": 368.5
},
{
"t": 2298,
"x": 671,
"y": 369
},
{
"t": 2315,
"x": 667.5,
"y": 370
},
{
"t": 2333,
"x": 664.5,
"y": 370
},
{
"t": 2348,
"x": 660.5,
"y": 370
},
{
"t": 2365,
"x": 656.5,
"y": 370
},
{
"t": 2382,
"x": 653,
"y": 370.5
},
{
"t": 2399,
"x": 650,
"y": 370.5
},
{
"t": 2415,
"x": 647.5,
"y": 370.5
},
{
"t": 2432,
"x": 644,
"y": 370.5
},
{
"t": 2449,
"x": 640.5,
"y": 370.5
},
{
"t": 2460,
"x": 638.5,
"y": 370.5
},
{
"t": 2478,
"x": 635,
"y": 370
},
{
"t": 2498,
"x": 630,
"y": 370
},
{
"t": 2515,
"x": 628,
"y": 370
},
{
"t": 2531,
"x": 625.5,
"y": 370
},
{
"t": 2549,
"x": 623,
"y": 370
},
{
"t": 2565,
"x": 620,
"y": 370
},
{
"t": 2584,
"x": 618,
"y": 370
},
{
"t": 2594,
"x": 617,
"y": 370
},
{
"t": 2609,
"x": 615,
"y": 370
},
{
"t": 2626,
"x": 613.5,
"y": 370
},
{
"t": 2643,
"x": 612.5,
"y": 370
},
{
"t": 2697,
"x": 614.5,
"y": 370
},
{
"t": 2705,
"x": 615,
"y": 370
},
{
"t": 2727,
"x": 616,
"y": 370.5
}
],
"startTime": 2014,
"strokeColor": "#F8A602",
"strokeWidth": 4,
"type": "pen"
}
],
"endTime": 2727,
"id": 1,
"startTime": 0,
"type": "recording"
}
],
"platform": "iOS",
"width": 1344
}
但它只适用于“句点”部分!
谁能提供一些帮助?
我是一名优秀的程序员,十分优秀!