The following Python script:
import os
print os.listdir('D:\images')
is outputing the names of all the folders in the D:\image
directory, but it is also showing desktop.ini
in the same folder, while there is no such file in the image directory.
Its also not a hidden item, I am sure of that.
Why is it then showing it as a content?
desktop.ini
is a protected system file, and Windows tends to hide it.You can verify by going to
D:\images
in a terminal and runningdir /A
.See this answer as well.
You can use
os.walk()
if you want more control, it will give you directories and files separately. You can also useos.path.isdir()
to find out if an entry you get is a directory.