Windows error 5: Access is denied when trying delete a directory in windows

前端 未结 4 2087
天涯浪人
天涯浪人 2021-01-01 06:11

i am trying to delete a directory but when i run the code it gives windows error 5: access is denied. here is my code: in the Release folder, there is a folder called

4条回答
  •  生来不讨喜
    2021-01-01 06:45

    This was due to the file permissions issue.

    You need to have the permissions to perform that task on that file.

    To get the permissions associated with a file, useos.stat(fileName)

    You can explicitly check the write permission for that file using os.access(fileName, os.W_OK)

    Then, to change the permission, os.chmod(fileName,permissionNumeric).

    Ex: os.chmod(fileName, '0777')

    To change the permission for the current file that is being executed, use os.chmod(__file__, '0777')

提交回复
热议问题