Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The official example of glob
>>> import glob
>>> glob.glob('./[0-9].*')
['./1.gif', './2.txt']
>>> glob.glob('*.gif')
['1.gif', 'card.gif']
>>> glob.glob('?.gif')
['1.gif']
>>> glob.glob('**/*.txt', recursive=True)
['2.txt', 'sub/3.txt']
>>> glob.glob('./**/', recursive=True)
['./', './sub/']
>>> import glob
>>> glob.glob('*.gif') #find .gif file
['card.gif']
>>> glob.glob('.c*') #find .gif file whose names start with.
['.card.gif']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment