[英]how can i Extract JSON from HTTP Response (python)
i get this from lambda api gateway.我从 lambda api 网关得到这个。 how can i get {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n} to json style ?
我怎样才能得到 {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n} 到 json 样式?
"------WebKitFormBoundarySfqiG2UABUZYF7Ir\r\n
Content-Disposition: form-data;
name=\"upload-file\";
filename=\"example.json\"\r\n
Content-Type: application/json\r\n\r\n
{\n \"a\":\"b\",\n \"c\":\"d\",\n \"e\":\"f\",\n \"g\":\"h\"\n}
\r\n------WebKitFormBoundarySfqiG2UABUZYF7Ir--"
i want make this {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n}我想让这个 {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n}
to至
{
"a":"b",
"c":"d",
"e":"f",
"g":"h"
}
How do you handle a response to get this?你如何处理回应以获得这个?
Try this试试这个
import json
result = json.loads(x[x.find('{'): x.find('}')+1])
x is your string x 是你的字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.