FileNotFoundError: [Errno 2] No such file or directory: ''
jak
nospam at please.ty
Wed Apr 14 13:35:45 EDT 2021
Il 14/04/2021 18:13, Quentin Bock ha scritto:
> I receive this error when I try to open a file
> The file (what I'm trying to open) is in the same folder as the program I'm
> trying to open it from; why is it saying no such file or directory?
>
> this is the only part of the code that causes the error
>
> file = open('Egils Saga 1-15.txt', "r")
>
> file.close()
>
>>> file = open('Egils Saga 1-15.txt', "r")
>>> file.read()
'Hello from Egils Saga 1-15.txt'
>>> file.close()
Try to check your 'current working directory':
>>> import os
>>> os.getcwd()
'D:\\tmp' # where the file is
>>>
More information about the Python-list
mailing list