📜  更新嵌套字典 python 代码示例

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

代码示例1
import collections.abc

def update(d, u):
    for k, v in u.items():
        if isinstance(v, collections.abc.Mapping):
            d[k] = update(d.get(k, {}), v)
        else:
            d[k] = v
    return d