utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mimesis 作者: lk-geimfari 项目源码 文件源码
def update_dict(initial: JSON, other: Mapping) -> JSON:
    """Recursively update a dictionary.

    :param initial: Dict to update.
    :type initial: dict or list
    :param other: Dict to update from.
    :type other: Mapping
    :return: Updated dict.
    :rtype: dict
    """
    for key, value in other.items():
        if isinstance(value, collections.Mapping):
            r = update_dict(initial.get(key, {}), value)
            initial[key] = r
        else:
            initial[key] = other[key]
    return initial
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号