Python:errno13:尝试复制文件夹时权限被拒绝

问题描述 投票:0回答:1

[浏览过许多其他[errno13]帖子,但没有发现任何有用的信息。

文件目录如下:

C:\\Users\\My HP\\Desktop\\Python\\Automate_the_boring_stuff\\Misc\\Eating\\Pie\\carrot.txt

这是我复制文件夹的代码:

for folderTitle, childFolders, fileNames in os.walk('C:\\Users\\My HP\\Desktop\\Python\\Automate_the_boring_stuff\\Misc\\Eating'):

     for folder in childFolders:
         shutil.copy(folder, folder + '_backup')

运行此命令将导致'errno13: Permission denied'错误。文件夹是否以某种方式在“使用中”或不可复制?据我所知,它们没有在Windows中打开。任务管理器显示Windows资源管理器处于非活动状态。

这个问题在我尝试过的每个编辑器中都存在(Geany,IDLE和jupyter是我有权使用的那些。)>

(顺便说一句,如果您尝试导入shell实用程序,则在IDLE中打开Python脚本会导致错误;该错误指出无法找到shutil。Geany/ Jupyter没有此问题)。

有人可以帮忙吗?

[浏览过其他许多'errno13'帖子,但没有发现任何有用的信息。文件目录如下:C:\\ Users \\ My HP \\ Desktop \\ Python \\ Automate_the_boring_stuff \\ Misc \\ Eating \\ ...

python errno
1个回答
0
投票
import os
path = r"D:\test"
file_path = r"D:\tmp.txt"
while(True):
    print(len(path))
    os.mkdir(path)
    new_file_path = os.path.join(path,file_path)
    os.rename(file_path,new_file_path)
    file_path = new_file_path
    path = os.path.join(path,"test")
© www.soinside.com 2019 - 2024. All rights reserved.