【问题标题】:Errno13 - Permission denied in documents folder?Errno 13 - 文档文件夹中的权限被拒绝?
【发布时间】:2015-01-31 11:20:47
【问题描述】:

好的,我在一个允许用户创建项目的代码上工作了一个小时,但现在我太棒了。我尝试使用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()

开始:

if __name__ == '__main__':
    adder = Adder()
    adder.AddResource('/users/jan/downloads/', 'polygon_grey_background.jpg', '/users/jan/documents/', 'MyCoolScene')

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

Traceback(最近一次调用最后一次):文件“project.py”,第 28 行,在 adder.AddResource('/users/jan/downloads/', 'polygon_grey_background.jpg', '/users/jan/documents/', 'MyCoolScene') 文件“project.py”,第 21 行,在 AddResource 中 shutil.copyfile(resourcepath + resourcename, resfo) # 将资源复制到资源文件夹 File "C:\Python27\lib\shutil.py", 第 83 行,在副本文件中 使用 open(dst, 'wb') 作为 fdst: IOError: [Errno 13] Permission denied: '/users/jan/documents/MyCoolScene/MyCoolS cene.sceneproj/project.scresources'

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

~一月

【问题讨论】:

    标签: python io copy errno shutil


    【解决方案1】:

    通过使用copy 而不是copyfile 解决了这个问题。

    【讨论】:

    • 虽然不是我的情况
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 2011-06-11
    • 2014-07-15
    • 2015-07-17
    • 2016-07-25
    • 2013-06-12
    相关资源
    最近更新 更多