求助启信宝接口Json问题
import requestsimport json
import demjson
# 接口信息
baseUrl = 'https://api.'
# 请求参数
urlParams = {
'appkey': '****************',
'secret_key': '******************',
'keyword': '911507006640921395'
}
concatParams = []
for key, value in urlParams.items():
concatParams.append('{}={}'.format(key, value))
# 构造url
url = '{}?{}'.format(baseUrl, '&'.join(concatParams))
# 调用接口
response = requests.get(url)
# 处理响应数据
jsonContent = json.dumps(str(response.content, encoding = 'utf-8'))
rspResult = jsonContent.encode('utf-8').decode('unicode-escape')
py_json = demjson.decode(rspResult)
最后一句出错 demjson.JSONDecodeError: Unexpected text after end of JSON value
rspResult的值为:
"{"status":"200","message":"操作成功","sign":"2bdc69a2b64daab10a5b9b80a4425e7b","data":{"id":"0e585a17-5935-4646-9556-103861254465","name":"大唐呼伦贝尔化肥有限公司","format_name":"大唐呼伦贝尔化肥有限公司","econKind":"有限责任公司(非自然人投资或控股的法人独资)(1153)","econKindCode":"1153","registCapi":"54820 万人民币","currency_unit":"CNY","type_new":"01","historyNames":[],"address":"内蒙古自治区呼伦贝尔经济技术开发区(谢尔塔拉)和谐路29号","regNo":"152100000000033","scope":"许可经营项目:无 一般经营项目:生产、销售合成氨、尿素、工业氧、工业氮、工业硫磺","termStart":"2007-09-04","termEnd":"2027-09-03","belongOrg":"呼伦贝尔市市场监督管理局","operName":"邓永斌","title":"法定代表人","startDate":"2007-09-04","endDate":"-","checkDate":"2022-09-05","status":"存续","new_status":"存续","orgNo":"664092139","creditNo":"911507006640921395","districtCode":"150700","actualCapi":"54820 万人民币","categoryNew":"0115601","domain":"C2600","tags":[],"revoke_reason":"-","logout_reason":"-","revoke_date":"-","fenname":"-"}}"
rspResult值前后有两个双引号,手工去掉就可以了,请问各位大神是什么原因啊。
[此贴子已经被作者于2023-5-20 22:00编辑过]