10.8. fnmatch — Unix filename pattern matching — Python 2.7.18 documentation

PHOTO EMBED

Wed Nov 11 2020 19:44:40 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol

import fnmatch
import os

for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.txt'):
        print file
content_copyCOPY

https://docs.python.org/2/library/fnmatch.html