Python open() gives FileNotFoundError/IOError: Errno 2 No such file or directory

前端 未结 5 1293
孤街浪徒
孤街浪徒 2020-11-22 06:24

For some reason my code is having trouble opening a simple file:

This is the code:

file1 = open(\'recentlyUpdated.yaml\')

And the erro

5条回答
  •  醉话见心
    2020-11-22 07:10

    The file may be existing but may have a different path. Try writing the absolute path for the file.

    Try os.listdir() function to check that atleast python sees the file.

    Try it like this:

    file1 = open(r'Drive:\Dir\recentlyUpdated.yaml')
    

提交回复
热议问题