glob
The glob module returns all filenames in a directory that match a pattern specified using the rules of the UNIX shell (as described in the fnmatch module).
glob(pattern)
Returns a list of pathnames that match pattern.
Example
glob('*.html')
glob('image[0-5]*.gif')
Note
Tilde (~) and shell variable expansion are not performed. Use os.path.expanduser() and os.path.expandvars(), respectively, to perform these expansions prior to calling glob().
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.