gpt4 book ai didi

python - 如果特定键与查询匹配,如何获取所有键/值?

转载 作者:太空宇宙 更新时间:2023-11-03 21:38:52 25 4
gpt4 key购买 nike

在 python 中,我正在访问一个返回警报列表的 API,如下所示:

{
"items": [
{
"AlertID": 0,
"Code": 0,
"Source": "string",
"Title": "string",
"Severity": "Information",
"Created": "2018-10-29T14:57:05.639Z",
"ThresholdValue1": "string",
"ThresholdValue2": "string",
"ThresholdValue3": "string",
"ThresholdValue4": "string",
"ThresholdValue5": "string",
"SnoozedEndDate": "2018-10-29T14:57:05.639Z",
"DeviceGuid": "string",
"AdditionalInfo": "string",
"Archived": true,
"AlertCategoryID": "Hardware",
"ArchivedDate": "2018-10-29T14:57:05.639Z",
"TicketID": 0,
"AlertMessage": "string",
"DeviceName": "string",
"CustomerID": 0,
"CustomerName": "string",
"MessageTemplate": "string",
"FolderID": 0,
"PollingCyclesCount": 0
}
],
"totalItemCount": 0,
"page": 0,
"itemsInPage": 0,
"totalPages": 0,
"prevLink": "string",
"nextLink": "string"
}

这将返回包含 20 个警报的列表。如果我想打印“已存档”键值为“假”的任何警报的所有详细信息,最好的方法是什么?我只需要查看有关当前警报的详细信息,而不是存档的警报。如果我也传入特定的 AlertID,API 还可以返回详细信息,这个特定的 url 为我提供了所有警报的列表。

最佳答案

for alert in result['items']:
if alert.get('Archived') is False:
print(alert)

关于python - 如果特定键与查询匹配,如何获取所有键/值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53048361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com