PermissionError: [Errno 13] in Python(PermissionError:Python 中的 [Errno 13])
问题描述
刚开始学习一些 Python,我遇到了如下所述的问题:
Just starting to learn some Python and I'm having an issue as stated below:
a_file = open('E:Python Win7-64-AMD 3.3Test', encoding='utf-8')
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
a_file = open('E:Python Win7-64-AMD 3.3Test', encoding='utf-8')
PermissionError: [Errno 13] Permission denied: 'E:\Python Win7-64-AMD 3.3\Test
似乎是文件权限错误,如果有人能发光,将不胜感激.
Seems to be a file permission error, if any one can shine some light it would be greatly appreciated.
注意:不确定 Python 和 Windows 文件如何工作,但我以管理员身份登录到 Windows,并且该文件夹具有管理员权限.
我已尝试将 .exe
属性更改为以管理员身份运行.
I have tried changing .exe
properties to run as Admin.
推荐答案
什么时候做;
a_file = open('E:Python Win7-64-AMD 3.3Test', encoding='utf-8')
...您正在尝试将 目录 作为文件打开,这可能(并且在大多数非 UNIX 文件系统上)会失败.
...you're trying to open a directory as a file, which may (and on most non UNIX file systems will) fail.
你的另一个例子;
a_file = open('E:Python Win7-64-AMD 3.3Testa.txt', encoding='utf-8')
如果您只有 a.txt
的权限,应该可以正常工作.您可能希望使用原始(r
-prefixed)字符串,以确保您的路径不包含任何转义字符,如
将被转换为特殊字符.
should work well if you just have the permission on a.txt
. You may want to use a raw (r
-prefixed) string though, to make sure your path does not contain any escape characters like
that will be translated to special characters.
a_file = open(r'E:Python Win7-64-AMD 3.3Testa.txt', encoding='utf-8')
这篇关于PermissionError:Python 中的 [Errno 13]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PermissionError:Python 中的 [Errno 13]


- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 沿轴计算直方图 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01