fnmatch模块: 优点在于提供对Unix Shell通配符的支持
Pattern Meaning
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any character not in seq
* matches everything
? matches any single character
[seq] matches any character in seq
[!seq] matches any character not in seq
- import fnmatch
- for file in os.listdir('.'):
- if fnmatch.fnmatch(file, '*.py'):
- print file
- import os
- import glob
- for f in glob.glob(os.path.join(os.path.abspath('.'), '*')):
- print f