Errno13文档文件夹中的权限被拒绝?

2024-06-26 15:00:20 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,我花了一个小时编写了一个允许用户创建一个项目的代码,但是现在我很惊讶。我尝试使用shutilcopyfile复制文件。这是我的代码:

class Adder():
    @staticmethod
    def AddResource(resourcepath,resourcename,rootpath,projectname):
        resfi = rootpath + projectname + "/" + projectname + ".sceneproj/Resources"
        resfo = rootpath + projectname + "/" + projectname + ".sceneproj/project.scresources"
        shutil.copyfile(resourcepath + resourcename, resfo) # copy resource into resource folder
        with open(resfi, 'a') as resfile:
            resfile.write("project.scresources/" + resourcename)
            resfile.close()

开始时:

^{pr2}$

但现在我遇到了以下问题:

Traceback (most recent call last): File "project.py", line 28, in adder.AddResource('/users/jan/downloads/', 'polygon_grey_background.jpg', '/ users/jan/documents/', 'MyCoolScene') File "project.py", line 21, in AddResource shutil.copyfile(resourcepath + resourcename, resfo) # copy resource into res ource folder File "C:\Python27\lib\shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 13] Permission denied: '/users/jan/documents/MyCoolScene/MyCoolS cene.sceneproj/project.scresources'

意思是我没有复制文件的权限?但它是我的Documents文件夹?我该怎么解决这个问题?在

~简


Tags: pyprojectresourcefileshutilprojectnamecopyfileresfile