Python桌面清理器 - 访问Deined

时间:2017-07-16 09:22:55

标签: python

最近我发现了一个清理文件夹的程序。这是编码。

import os 
import shutil
lis=[]
destinationDir='C:\Users\Owner\All in two'
os.makedirs(destinationDir)
lis=os.listdir('C:\Users\Owner\My Documents')
for x in lis:
    if x==__file__:
        continue
    shutil.move(x,destinationDir)

当我尝试运行时,它会出错:

Traceback (most recent call last):
  File "C:\Users\Owner\Desktop\Cleaner.py", line 6, in <module>
    lis=os.listdir('C:\Users\Owner\My Documents')
WindowsError: [Error 5] Access is denied: 'C:\\Users\\Owner\\My Documents/*.*'

我尝试在管理员中使用cmd,但失败了。 所有建议都表示赞赏。

1 个答案:

答案 0 :(得分:0)

确保您的计算机具有相应的权限!

右键单击文件夹(我的文档或里面的文件夹)并查看安全性,如果您拥有带有勾选框的所有权限,则不应出现此错误!

基本上,如果您不是管理员或无法访问我的文档,那么您就无法运行它!

希望这有助于XD

相关问题