这将做您想要的:
result = [{**x, **y} for x, y in zip(list_1, list_2)]# [{'a': 'b', 'hello': 'world'}, {'c': 'd', 'foo': 'test'}]有关语法的说明,请参见PEP 448
**。
对于通用解决方案:
list_1=[{'hello':'world'},{'foo':'test'}]list_2=[{'a':'b'},{'c':'d'}]list_3=[{'e':'f'},{'g':'h'}]lists = [list_1, list_2, list_3]def merge_dicts(*dict_args): result = {} for dictionary in dict_args: result.update(dictionary) return resultresult = [merge_dicts(*i) for i in zip(*lists)]# [{'a': 'b', 'e': 'f', 'hello': 'world'}, {'c': 'd', 'foo': 'test', 'g': 'h'}]


