{ "@odata.context": "/redfish/v1/$metadata#EthernetInterfaceCollection.EthernetInterfaceCollection", "@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces", "@odata.type": "#EthernetInterfaceCollection.EthernetInterfaceCollection", "Description": "Collection of Ethernet Interfaces for this Manager", "Name": "Ethernet Network Interface Collection", "Members@odata.count": 1, "Members": [{ "@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces/744A65146514" }], "@odata.etag": "W/\"5897b895315588b4c40946b1dad10e97\"" } python 提取出来嵌套字典中Members中的744A65146514数字
时间: 2023-08-11 19:08:54 浏览: 196
SAP Fiori_Training_Day_2.pdf
您可以使用Python代码来提取嵌套字典中Members字段中的744A65146514数字。以下是一个示例代码:
```python
data = {
"@odata.context": "/redfish/v1/$metadata#EthernetInterfaceCollection.EthernetInterfaceCollection",
"@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces",
"@odata.type": "#EthernetInterfaceCollection.EthernetInterfaceCollection",
"Description": "Collection of Ethernet Interfaces for this Manager",
"Name": "Ethernet Network Interface Collection",
"Members@odata.count": 1,
"Members": [
{
"@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces/744A65146514"
}
],
"@odata.etag": "W/\"5897b895315588b4c40946b1dad10e97\""
}
member_id = data["Members"][0]["@odata.id"].split("/")[-1]
print(member_id)
```
这段代码将打印出 `744A65146514`。它首先通过键名 `"Members"` 获取到列表,然后通过索引 `[0]` 获取到列表中的第一个字典。接着通过键名 `"@odata.id"` 获取到对应的值,最后使用 `split("/")[-1]` 来获取该值中最后一个斜杠后面的内容。
阅读全文