Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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 - Fatal编程技术网

如果python中的值相同,则在列表中合并词典

如果python中的值相同,则在列表中合并词典,python,Python,我有一个字典列表,如下所示 , {'id':2201187803,'wind':0,'nstid':294269,'amrcd':1,'insno':'10年修复,'fileid':2007498393,'arstname':'Amy','amcd':1,'atlstnme':'America'}] 我的输出JSON应该是这样的,因为字段id是公共的,有值JSON应该附加在一起如果您使用代码下面的python 3.x引用 ds = [d1, d2] d = {} for k in d1.key

我有一个字典列表,如下所示

,
{'id':2201187803,'wind':0,'nstid':294269,'amrcd':1,'insno':'10年修复,'fileid':2007498393,'arstname':'Amy','amcd':1,'atlstnme':'America'}]

我的输出JSON应该是这样的,因为字段
id
是公共的,有值JSON应该附加在一起

如果您使用代码下面的python 3.x引用

ds = [d1, d2]
d = {}
for k in d1.keys():
   d[k] = tuple(d[k] for d in ds)