好友
阅读权限20
听众
最后登录1970-1-1
|
请教 json数据 提取指定数值的方法
还没确定的思路提取数值的方法 想到了正则表达式 但还不会
源数据:
[Plain Text] 纯文本查看 复制代码 {
"code" : 1001,
"msg" : "succ",
"result" : {
"paper" : {
"createId" : 1,
"createTs" : "2022-03-08 11:24:42",
"id" : 10048,
"isRandom" : 1,
"name" : "每日答题",
"passScore" : 0,
"publish" : "Y",
"sourceId" : 0,
"sourceType" : 0,
"status" : "Y",
"totalScore" : 5,
"type" : 5,
"updateId" : null,
"updateTs" : null
},
"questions" : {
"answer" : [],
"judge" : [
{
"checkOption" : null,
"context" : null,
"factScore" : null,
"optionList" : [],
"paperId" : 10048,
"questionId" : 496,
"questionTitle" : "判断下面说法是否正确:二氧化碳是火灾中致死的主要燃烧产物之一,能阻碍人体血液中氧气的输送,引起头痛、虚脱、神志不清等症状和肌肉调节障碍等。",
"recordId" : null,
"score" : 1,
"status" : 0,
"trueOption" : "B、错",
"type" : null,
"url" : "F"
}
],
"mutil" : [
{
"checkOption" : null,
"context" : null,
"factScore" : null,
"optionList" : [
{
"content" : "灭火器",
"id" : 1548,
"index" : 0,
"isRight" : null,
"type" : null
},
{
"content" : "报警电话",
"id" : 1549,
"index" : 1,
"isRight" : null,
"type" : null
},
{
"content" : "火灾事故应急照明灯",
"id" : 1550,
"index" : 2,
"isRight" : null,
"type" : null
},
{
"content" : "灯光疏散指示标志",
"id" : 1551,
"index" : 3,
"isRight" : null,
"type" : null
},
{
"content" : "低压电气漏电保护报警器",
"id" : 1552,
"index" : 4,
"isRight" : null,
"type" : null
}
],
"paperId" : 10048,
"questionId" : 469,
"questionTitle" : "公共娱乐场所按规定一般应设置的消防安全设施、设备包括( )。",
"recordId" : null,
"score" : 1,
"status" : 0,
"trueOption" : "A,灭火器 B,报警电话 C,火灾事故应急照明灯 D,灯光疏散指示标志 ",
"type" : null,
"url" : "1548,1549,1550,1551,"
}
],
"single" : [
{
"checkOption" : null,
"context" : null,
"factScore" : null,
"optionList" : [
{
"content" : "液化石油气",
"id" : 1335,
"index" : 0,
"isRight" : null,
"type" : null
},
{
"content" : "热水器",
"id" : 1336,
"index" : 1,
"isRight" : null,
"type" : null
},
{
"content" : "天然气",
"id" : 1337,
"index" : 2,
"isRight" : null,
"type" : null
},
{
"content" : "电饭煲",
"id" : 1338,
"index" : 3,
"isRight" : null,
"type" : null
}
],
"paperId" : 10048,
"questionId" : 416,
"questionTitle" : "设置在地下建筑内的公共娱乐场所严禁使用( )。",
"recordId" : null,
"score" : 1,
"status" : 0,
"trueOption" : "A,液化石油气 ",
"type" : null,
"url" : "1335,"
},
{
"checkOption" : null,
"context" : null,
"factScore" : null,
"optionList" : [
{
"content" : "液化石油气",
"id" : 1471,
"index" : 0,
"isRight" : null,
"type" : null
},
{
"content" : "蜂窝煤",
"id" : 1472,
"index" : 1,
"isRight" : null,
"type" : null
},
{
"content" : "天然气",
"id" : 1473,
"index" : 2,
"isRight" : null,
"type" : null
},
{
"content" : "电饭煲",
"id" : 1474,
"index" : 3,
"isRight" : null,
"type" : null
}
],
"paperId" : 10048,
"questionId" : 450,
"questionTitle" : "设置在地下建筑内的公共娱乐场所严禁使用( )。",
"recordId" : null,
"score" : 1,
"status" : 0,
"trueOption" : "A,液化石油气 ",
"type" : null,
"url" : "1471,"
},
{
"checkOption" : null,
"context" : null,
"factScore" : null,
"optionList" : [
{
"content" : "重大火灾事故",
"id" : 1331,
"index" : 0,
"isRight" : null,
"type" : null
},
{
"content" : "较大火灾事故",
"id" : 1332,
"index" : 1,
"isRight" : null,
"type" : null
},
{
"content" : "特别重大火灾事故",
"id" : 1333,
"index" : 2,
"isRight" : null,
"type" : null
},
{
"content" : "一般火灾事故",
"id" : 1334,
"index" : 3,
"isRight" : null,
"type" : null
}
],
"paperId" : 10048,
"questionId" : 415,
"questionTitle" : "某娱乐城发生火灾,过火面积约300平方米,当场造成7人死亡,3人重伤。3名重伤者分别在火灾事故发生后的第2天、第5天、第8天死亡。该起火灾事故属于( )。",
"recordId" : null,
"score" : 1,
"status" : 0,
"trueOption" : "B,较大火灾事故 ",
"type" : null,
"url" : "1332,"
}
]
}
}
}
提取后的数据应该如这般:
[Plain Text] 纯文本查看 复制代码 [
{
"checkOption" : 1335,
"questionId" : 416,
"status" : 0
},
{
"checkOption" : 1471,
"questionId" : 450,
"status" : 0
},
{
"checkOption" : 1332,
"questionId" : 415,
"status" : 0
},
{
"checkOption" : "1548,1549,1550,1551",
"questionId" : 469,
"status" : 0
},
{
"context" : "F",
"questionId" : 496,
"status" : 0
}
]
好像每个 questionId 靠近的 url 值就能组成提取后的目标 json 同组的 questionId 与 url
怎么在python里面提取 到呢? |
|