I am Charmie

メモとログ

Python: load a list of file names in a directory

There are two functions, os.listdir and glob.glob, for the purpose.

os.listdir loads all the filenames in the specified directory. [code lang="python"] import os filelist = os.listdir('dirName/') [/code]

glob.glob loads all the filenames in the specified directory and we can use wildcard . [code lang="python"] import glob filelist = glob.glob('dirName/.png') [/code]