utils.py 文件源码

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

项目:statik 作者: thanethomson 项目源码 文件源码
def dict_strip(d):
    """Strips whitespace from the string values of the given dictionary (recursively).

    Args:
        d: A dictionary object.

    Returns:
        A new dictionary object, whose string values' whitespace has been stripped out.
    """
    _d = deepcopy(d)
    for k, v in iteritems(d):
        if isinstance(v, str):
            _d[k] = v.strip()
        elif isinstance(v, dict):
            _d[k] = dict_strip(v)

    return _d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号