Python `OS` package doesn't open files in order

22 Views Asked by At

I am trying to open bunch of .tif files and do some processing on them. I am using the following code to do this:

for images in os.listdir(folder_dir):
    if (images.endswith(".tif")):
        print(images)

The code works perfect; however, the only slight issue I have is that in one case, the files are not opened in order. See image below:

enter image description here

In the above example, it's clearly shown that picture #100 will be opened after picture #10. I expected to picture #100 will be opened after picture #99.

does anyone know why this is happening and how I can fix it?

0

There are 0 best solutions below