errno 13: permission denied in vscode

Viewed 45

[ VSCODE ] it's a simple code to read a text file, but it keeps giving me errno 13

with open('movie.txt') as file_object:
    content = file_object.read()
    print(content.strip())

the file is saved as movie.txt, but when i used that it said there was no file under that name, when I do in fact have it saved. when i changed changed to with open('movie'), without the .txt extension, it said permission error. I've searched everywhere but i cant find the solution.

UPDATE : works if i use absolute path.

1 Answers

Your question is answered here. There is a directory named movie in your directory structure, which makes vscode open a directory instead of a file.

What you need to do is replace movie with movie.txt:

with open("movie.txt") as file_object:
    content = file_object.read()
    print(content.strip())
Related