正在尝试转换用于在字典中查找特定键值的值列表。你知道吗
我想不出一个可行的方法。你知道吗
尝试将列表转换为字符串并将其作为键传递给字典,但由于列表中也包含整数值,因此现在可以使用。你知道吗
l = ['tsGroups', 0, 'testCases', 0, 'parameters', 'GnbControlAddr', 'ip']
d={
"tsGroups": [{"tsId": 19,
"testCases": [{"name": "abcd",
"type": "xyz",
"parameters": {"GnbControlAddr":
{"ip": "192.1.1.1",
"mac": "",
"mtu": 1500,
"phy": "eth2",
}
}
}]
}]
}
print(d["tsGroups"][0]["testCases"][0]["parameters"]["GnbControlAddr"]
["ip"])
需要将输入列表“l”转换为用作
d["tsGroups"][0]["testCases"][0]["parameters"]["GnbControlAddr"]["ip"]
无法说明这有多像python,但循环遍历列表并更新对新数据结构的引用似乎是可行的:
相关问题 更多 >
编程相关推荐