python提取json里面多个相同key的值
怎么提取出里面的所有DetectedText下的值啊?{"TextDetections":[{"DetectedText":"参考合向:WY.J20190505金额:12...
怎么提取出里面的所有DetectedText下的值啊?
{"TextDetections": [{"DetectedText": "参考合向: WY.J20190505金额: 12004元", "Confidence": 85, "Polygon": [{"X": 7, "Y": 16}, {"X": 190, "Y": 16}, {"X": 190, "Y": 28}, {"X": 7, "Y": 28}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}, {"DetectedText": "发票须按如下要求开段:", "Confidence": 91, "Polygon": [{"X": 7, "Y": 46}, {"X": 106, "Y": 46}, {"X": 106, "Y": 56}, {"X": 7, "Y": 56}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}, {"DetectedText": "品名:门但五金配性", "Confidence": 85, "Polygon": [{"X": 7, "Y": 60}, {"X": 95, "Y": 60}, {"X": 95, "Y": 71}, {"X": 7, "Y": 71}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}"}, {"DetectedText": "数量: 460千克", "Confidence": 82, "Polygon": [{"X": 7, "Y": 74}, {"X": 70, "Y": 74}, {"X": 70, "Y": 85}, {"X": 7, "Y": 85}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":3}}"}, {"DetectedText": "医注: WY.J201 90505", "Confidence": 81, "Polygon": [{"X": 8, "Y": 88}, {"X": 98, "Y": 88}, {"X": 98, "Y": 99}, {"X": 8, "Y": 99}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":4}}"}], "Language": "zh", "RequestId": "d8a7a0cb-1ae6-40fa-9a90-6bdcc27bea68"} 展开
{"TextDetections": [{"DetectedText": "参考合向: WY.J20190505金额: 12004元", "Confidence": 85, "Polygon": [{"X": 7, "Y": 16}, {"X": 190, "Y": 16}, {"X": 190, "Y": 28}, {"X": 7, "Y": 28}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}, {"DetectedText": "发票须按如下要求开段:", "Confidence": 91, "Polygon": [{"X": 7, "Y": 46}, {"X": 106, "Y": 46}, {"X": 106, "Y": 56}, {"X": 7, "Y": 56}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}, {"DetectedText": "品名:门但五金配性", "Confidence": 85, "Polygon": [{"X": 7, "Y": 60}, {"X": 95, "Y": 60}, {"X": 95, "Y": 71}, {"X": 7, "Y": 71}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":2}}"}, {"DetectedText": "数量: 460千克", "Confidence": 82, "Polygon": [{"X": 7, "Y": 74}, {"X": 70, "Y": 74}, {"X": 70, "Y": 85}, {"X": 7, "Y": 85}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":3}}"}, {"DetectedText": "医注: WY.J201 90505", "Confidence": 81, "Polygon": [{"X": 8, "Y": 88}, {"X": 98, "Y": 88}, {"X": 98, "Y": 99}, {"X": 8, "Y": 99}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":4}}"}], "Language": "zh", "RequestId": "d8a7a0cb-1ae6-40fa-9a90-6bdcc27bea68"} 展开
展开全部
注意到第一个"TextDetections"是个list,所以你可以用for循环来读取它:
for item in dict["TextDetections"]: # 每一个item又是一个dict
print(item["TextDetections"]) # 这就读取到了。
for item in dict["TextDetections"]: # 每一个item又是一个dict
print(item["TextDetections"]) # 这就读取到了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询