shutil.rmtree(path)
报错:PermissionError: [WinError 5]
分析:对应的目录或文件被设置了只读属性
解决方案:
def remove_readonly(func, path, _): # 错误回调函数,改变只读属性位,重新删除 "Clear the readonly bit and reattempt the removal" os.chmod(path, stat.S_IWRITE) func(path) shutil.rmtree(path, one rror=remove_readonly) # 设置错误回调函数οnerrοr=remove_readonly
参考文章:https://blog.csdn.net/qq_21444067/article/details/131036512
标签:Python,remove,readonly,报错,笔记,path,shutil From: https://www.cnblogs.com/lovewaits/p/17665672.html