I looking for a conceptual understanding of os.listdir()
. I used os.listdir()
to iterate through each file in my directory, however, a filename in os.listdir()
was not in the directory. This is the error I experienced:
FileNotFoundError: [Errno 2] No such file or directory: 'a29ydW5pc2hpLnR0Zg==.png'
After further inspection, I discovered this stack overflow entry: List files ONLY in the current directory
Because of this page, I suspect that the filenames in os.listdir() may not match the ones currently in the directory. I came to this conclusion because of os.path.isfile()
documentation suggests that sometimes extra file names might still be in os.listdir()
.
Why does os.listdir()
still contain entries of files that are no longer in the directory or why is this filename in os.listdir()
when it isn't in my directory?
Comments
Post a Comment