PermissionError: [Errno 13] Permission denied:

Looking at CSDN, they all said that the file was opened elsewhere, but I still reported an error here, so I found the answer on stackovderflow:

It means that you are opening a folder, but you need to open a file!

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

Guess you like

Origin blog.csdn.net/weixin_43135178/article/details/123701927