-> %pythonPython3.9.13|packagedbyconda-forge| (main,May272022,17:00:33) [Clang 13.0.1 ] on darwinType"help","copyright","credits"or"license"formoreinformation.>>> frompathlibimportPath>>> r=Path('.').absolute(); rPosixPath('/Users/huay/tmp/glob_test')# a*>>> for p inr.glob('a*'):print(p).../Users/huay/tmp/glob_test/a1.c/Users/huay/tmp/glob_test/a3.cpp/Users/huay/tmp/glob_test/a2.py# a[13]*>>> for p inr.glob('a[13]*'):print(p).../Users/huay/tmp/glob_test/a1.c/Users/huay/tmp/glob_test/a3.cpp# a[!13]*>>> for p inr.glob('a[!13]*'):print(p).../Users/huay/tmp/glob_test/a2.py# *.c*>>> for p inr.glob('*.c*'):print(p).../Users/huay/tmp/glob_test/a1.c/Users/huay/tmp/glob_test/a3.cpp# */*.c*>>> for p inr.glob('*/*.c*'):print(p).../Users/huay/tmp/glob_test/foo/c2.cpp/Users/huay/tmp/glob_test/foo/c3.c# **/*.cpp>>> for p inr.glob('**/*.cpp'):print(p).../Users/huay/tmp/glob_test/a3.cpp/Users/huay/tmp/glob_test/foo/c2.cpp/Users/huay/tmp/glob_test/foo/baz/b3.cpp/Users/huay/tmp/glob_test/foo/bar/d2.cpp# *.{py, cp*} Python 不支持>>> for p inr.glob('*.{py, cp*}'):print(p)...# *.?>>> for p inr.glob('*.?'):print(p).../Users/huay/tmp/glob_test/a1.c# */*.?>>> for p inr.glob('*/*.?'):print(p).../Users/huay/tmp/glob_test/foo/c3.c# */*/*.?>>> for p inr.glob('*/*/*.?'):print(p).../Users/huay/tmp/glob_test/foo/baz/b2.c/Users/huay/tmp/glob_test/foo/bar/d3.c