How to read filenames in a folder and access them in an alphabetical and increasing number order?
问题 I would like to ask how to efficiently handle accessing of filenames in a folder in the right order (alphabetical and increasing in number). For example, I have the following files in a folder: apple1.dat, apple2.dat, apple10.dat, banana1.dat, banana2.dat, banana10.dat. I would like to read the contents of the files such that apple1.dat will be read first and banana10.dat will be read last. Thanks. This is what I did so far. from glob import glob files=glob('*.dat') for list in files # I read