我正在使用 rest api 获取数据。我想在响应输出“数据”部分中用 null(或另一个数字)替换所有 0 值。
headers = {
"cookie": "JSESSIONID=....",
"Authorization": "Basic ...",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers, params=querystring, verify=False).text
响应输出:
{
"status": {
"total": 1,
"matched": 1,
"processed": 1,
"completed": true,
"aborted": false,
"hasErrors": false,
},
"result": [
{
"signature": "raidOwner#33414-SACONC1ANKT",
"syn_raidLdev_transferRate": [
{
"type": "timeseries",
"name": "Transfer Rate",
"unit": "KB/s",
"interval": 300,
"start": "20210627_230500",
"data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
}
],
},
{
"signature": "raidOwner#33414-BUTTE08",
"syn_raidLdev_transferRate": [
{
"type": "timeseries",
"name": "Transfer Rate",
"unit": "KB/s",
"interval": 300,
"start": "20210627_230500",
"data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
}
],
},
{
"signature": "raidOwner#33414-SREDMMAPP5",
"syn_raidLdev_transferRate": [
{
"type": "timeseries",
"name": "Transfer Rate",
"unit": "KB/s",
"interval": 300,
"start": "20210627_230500",
"data": [0, 3, 0, 3, 0, 3, 3, 0, 3, 0, 3, 0],
}
],
},
{
"signature": "raidOwner#33414-BUTTE01",
"syn_raidLdev_transferRate": [
{
"type": "timeseries",
"name": "Transfer Rate",
"unit": "KB/s",
"interval": 300,
"start": "20210627_230500",
"data": [
1814,
1609,
1279,
1394,
1320,
1249,
2002,
1329,
1270,
1359,
1284,
3383,
],
}
],
},
],
}
我需要在 "data": [] 值中用 null 替换所有 0 值。我怎样才能做到这一点?