python怎么从调用api返回的数据中取出指定值?
{"TextDetections":[{"DetectedText":"8my7","Confidence":99,"Polygon":[{"X":12,"Y":8},{...
{"TextDetections": [{"DetectedText": "8my7", "Confidence": 99, "Polygon": [{"X": 12, "Y": 8}, {"X": 90, "Y": 8}, {"X": 90, "Y": 32}, {"X": 12, "Y": 32}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}], "Language": "zh", "RequestId": "3a758f25-f8dd-48cb-8cc7-220d82bd6fcf"}
返回的json值,怎么只提出里面的DetectedText下的值:8my7 展开
返回的json值,怎么只提出里面的DetectedText下的值:8my7 展开
展开全部
返回的什么类型的数据,就用什么类型的变量去接收就行了,不太懂你的意思。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import json
s = r'{"TextDetections": [{"DetectedText": "8my7", "Confidence": 99, "Polygon": [{"X": 12, "Y": 8}, {"X": 90, "Y": 8}, {"X": 90, "Y": 32}, {"X": 12, "Y": 32}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}], "Language": "zh", "RequestId": "3a758f25-f8dd-48cb-8cc7-220d82bd6fcf"}'
j = json.loads(s)
print(j['TextDetections'][0]['DetectedText'])
s = r'{"TextDetections": [{"DetectedText": "8my7", "Confidence": 99, "Polygon": [{"X": 12, "Y": 8}, {"X": 90, "Y": 8}, {"X": 90, "Y": 32}, {"X": 12, "Y": 32}], "AdvancedInfo": "{\"Parag\":{\"ParagNo\":1}}"}], "Language": "zh", "RequestId": "3a758f25-f8dd-48cb-8cc7-220d82bd6fcf"}'
j = json.loads(s)
print(j['TextDetections'][0]['DetectedText'])
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询