小编Sar*_*avi的帖子

PermissionError: [WinError 5] 访问被拒绝

每次我尝试删除os.remove()Python 3.5.1 中使用的文件时,都会收到此消息PermissionError: [WinError 5] Access is denied

这是简单的代码:

def clean_thrash(path):
    dirlist=get_dirlist(path)
    for f in dirlist:
        fullname=os.path.join(path,f)
        if fullname == os.path.join(path,"thrash.txt"):
            os.remove(path)
        if os.path.isdir(fullname):
            clean_thrash(fullname)
Run Code Online (Sandbox Code Playgroud)

甚至没有删除目录或子目录中的单个文件。

python python-3.x

6
推荐指数
3
解决办法
2万
查看次数

标签 统计

python ×1

python-3.x ×1