Created
January 12, 2020 07:11
-
-
Save e96031413/19db962a7c5274086de02639cc6d4303 to your computer and use it in GitHub Desktop.
The official example of glob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> 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