📜  python 合并字典 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:31.924000             🧑  作者: Mango

代码示例6
def merge_dicts(dict1, dict2):
        """Here's an example of a for-loop being used abusively."""
        return {**dict2, **{k: (v if not (k in dict2) else (v + dict2.get(k)) if isinstance(v, list) else merge_dicts(v, dict2.get(k))) if isinstance(v, dict) else v for k, v in dict1.items()}}