recipe-578154.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def remove_directory_files(path, remove_directory=False, remove_path=False):
    "Remove directory at path, respecting the flags."
    for root, dirs, files in os.walk(path, False):
        # Ignore path if remove_path is false.
        if remove_path or root != path:
            for name in files:
                filename = os.path.join(root, name)
                try:
                    os.remove(filename)
                except OSError:
                    pass
            # Ignore directory if remove_directory is false.
            if remove_directory:
                try:
                    os.rmdir(root)
                except OSError:
                    pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号