Errno 13 权限被拒绝 Python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41910583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Errno 13 Permission denied Python
提问by Jake
In python, I am currently experimenting with what I can do with open
command. I tried to open a file, and got an error message. Here's my code:
在 python 中,我目前正在试验我可以用open
命令做什么。我试图打开一个文件,但收到一条错误消息。这是我的代码:
open(r'C:\Users\****\Desktop\File1')
My error message was:
我的错误信息是:
PermissionError: [Errno 13] Permission denied: 'C:\Users\****\Desktop\File1'
I looked on the website to try and find some answers and I saw a post where somebody mentioned chmod
. 1. I'm not sure what this is and 2. I don't know how to use it, and thats why I've come here.
我在网站上寻找一些答案,我看到有人提到的帖子chmod
。1. 我不确定这是什么 2. 我不知道如何使用它,这就是我来这里的原因。
采纳答案by dot.Py
Your user don't have the right permissions to read
the file, since you used open()
without specifying a mode.
您的用户没有read
对该文件的正确权限,因为您使用时open()
没有指定模式。
Since you're using Windows, you should read a little more about File and Folder Permissions.
由于您使用的是 Windows,您应该阅读更多关于File and Folder Permissions 的内容。
Also, if you want to play with your file permissions, you should right-click
it, choose Properties
and select Security
tab.
此外,如果您想使用您的文件权限,您应该right-click
选择Properties
并选择Security
选项卡。
Or if you want to be a little more hardcore, you can run your script as admin.
或者,如果您想变得更铁杆一点,您可以以管理员身份运行您的脚本。
SO Related Questions:
SO相关问题:
回答by Gaurav Shrivastava
The problem here is your user doesn't have proper rights/permissionsto open the file this means that you'd need to grant some administrative privileges to your python ide before you run that command.
这里的问题是您的用户没有打开文件的适当权限/权限,这意味着您需要在运行该命令之前向您的 python ide 授予一些管理权限。
As you are a windows user you just need to right click on python ide => select option 'Run as Administrator'and then run your command.
由于您是 Windows 用户,您只需要右键单击 python ide => 选择选项“以管理员身份运行”,然后运行您的命令。
And if you are using the command line to run the codes, do the same open the command prompt with admin rights. Hope it helps
如果您使用命令行运行代码,请使用管理员权限打开命令提示符。希望能帮助到你
回答by PythonMan
If you have this problem in Windows 10, and you know you have premisions on folder (You could write before but it just started to print exception PermissionError recently).. You will need to install Windows updates... I hope someone will help this info.
如果你在 Windows 10 中遇到这个问题,并且你知道你对文件夹有前提(你之前可以写,但它最近才开始打印异常 PermissionError)。你需要安装 Windows 更新......我希望有人能帮助这个信息。