PermissionError: [Errno 13] Permission denied:

看CSDN上,他们都说是有别的地方打开了文件,但是我这里还是报错,于是我再stackovderflow找到了答案:

意思就是你打开的是一个文件夹,但是需要打开的是一个文件才对!

his happens if you are trying to open a file, but your path is a folder.

This can happen easily by mistake.

To defend against that, use:

import os

path = r"my/path/to/file.txt"
assert os.path.isfile(path)
with open(path, "r") as f:
    pass

The assertion will fail if the path is actually of a folder.

python - PermissionError: [Errno 13] Permission denied - Stack Overflow

猜你喜欢

转载自blog.csdn.net/weixin_43135178/article/details/123701927