每次我尝试删除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)
甚至没有删除目录或子目录中的单个文件。