文件结构扁平化

2015-11-04 0 379
文件结构扁平化
def flatten(dictionary):
    stack = [((), dictionary)]
    result = {}
    while stack:
        path, current = stack.pop()
        if not current:
            result["/".join((path ))] = ""
        for k, v in current.items():
            if isinstance(v, dict):
                stack.append((path + (k,), v))
            else:
                result["/".join((path + (k,)))] = v
    return result

遇见资源网 python 文件结构扁平化 http://www.ox520.com/15864.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务