在python中将变量解析为键
我是python新手,正在试验JSON,这里我尝试从JSON中选择值(成员列表),但我有多个集群可以从中选择成员:在python中将变量解析为键,python,json,python-2.7,Python,Json,Python 2.7,我是python新手,正在试验JSON,这里我尝试从JSON中选择值(成员列表),但我有多个集群可以从中选择成员: with open("/some/path/example.json") as js: dcJson=json.load(js) i=1 print (dcJson["search"]["nodes"]["cluster{}"]["members"]).format
with open("/some/path/example.json") as js:
dcJson=json.load(js)
i=1
print (dcJson["search"]["nodes"]["cluster{}"]["members"]).format(i)
如何编写一些东西,以便调用dcJson[“搜索”][“节点”][“集群1”][“成员”]
非常感谢
dcJson["search"]["nodes"]["cluster{}".format(i)]["members"]