每次我尝试使用Python3.5.1中的os.remove()
删除文件时,都会收到此消息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)
甚至没有删除目录或子目录中的一个文件。
发布于 2016-05-23 01:08:36
如果您在Windows上,则必须是管理员用户;如果您在Linux上,则必须具有sudo权限。尝试使用sudo
运行代码
https://stackoverflow.com/questions/37377138
复制相似问题