I am trying to use the glob
module to make a list of all the Markdown files in my directory whose file paths contain either the strings abcd
or test
.
I know that this is successfully printing all the files in the directory:
print(glob.glob('**/*.md', recursive=True))
However, I want it to only match filepaths such as /home/users/a/abcd/one.md
or /home/users/b/test/two.md
or /home/users/c/subdir/test_or_abcd/three.md
. I want it to not match filepaths like /home/users/a/other/result.md
.
However, when I try to do this, it doesn't work:
print(glob.glob('**/*{abcd,test}.md', recursive=True))
Any suggestions or ideas on what I am doing wrong?
Do it as many filters u have ?
files = [
*glob.glob('**/*abcd.md', recursive=True),
*glob.glob('**/*test.md', recursive=True)
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.