有一个 Web 服务返回类似这样的内容,我想在这个响应中访问id。我该怎么办?
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">{"id":"1819","responseCode":"0","responseMessage":"0"}</string>
另外,我的功能在这里:
import requests
def sen_request():
url = "somewhere.com/somewhere.asmx/new_one"
payload = {}
headers= {}
response = requests.request("GET", url, headers=headers, data = payload)
return (response)
- 我尝试使用response.json()访问 JSON 中的响应,但出现此错误:
Exception Type: JSONDecodeError Exception Value: Expecting value: line 1 column 1 (char 0)