util.py 文件源码

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

项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码
def zip_dir(directory):
    """zip a directory tree into a BytesIO object"""
    result = io.BytesIO()
    dlen = len(directory)
    with ZipFile(result, "w") as zf:
        for root, dirs, files in os.walk(directory):
            for name in files:
                full = os.path.join(root, name)
                rel = root[dlen:]
                dest = os.path.join(rel, name)
                zf.write(full, dest)
    return result

#
# Simple progress bar
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号