【问题标题】:Open function permission denied only for image仅图像的打开功能权限被拒绝
【发布时间】:2021-08-23 10:38:36
【问题描述】:

我只是创建 test.py 文件并在其中编写以下代码。

open('test.jpg','wb')

我通过命令 Python test.py 运行它。然后我得到以下错误

 Traceback (most recent call last):
 File "test.py", line 2, in <module>
 open('test.jpg','wb')
 PermissionError: [Errno 13] Permission denied: 'img.jpg'

但是当我将扩展名更改为 .txt 时,它可以正常工作

open('test.txt','wb')

文件夹中不存在 test.jpg 和 test.txt

真正的问题是什么?

【问题讨论】:

    标签: python node.js image file permissions


    【解决方案1】:

    The PermissionError: [Errno 13] 在没有必要权限的情况下尝试从 Python 访问文件时出现权限被拒绝错误。通常,这个问题有两种解决方案:

    • 要修复此错误,请使用chmodchown 命令更改文件的权限,以便正确的用户和/或组可以访问该文件。您可能从 Internet 下载了该文件,因此您的 PC 可能会试图保护您。
    • 关闭您 PC 上打开的 .jpg 文件:当您处理该文件时,Python 无法处理该文件。

    【讨论】:

      猜你喜欢
      • 2013-01-08
      • 2011-07-31
      • 1970-01-01
      • 2013-03-13
      • 2020-05-31
      • 2023-03-22
      • 1970-01-01
      • 2018-09-08
      • 2018-03-20
      相关资源
      最近更新 更多