Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中将变量解析为键_Python_Json_Python 2.7 - Fatal编程技术网

在python中将变量解析为键

在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

我是python新手,正在试验JSON,这里我尝试从JSON中选择值(成员列表),但我有多个集群可以从中选择成员:

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"]