glob 是python 提供的一个支持正则表达式的查找文件的模块。
实现上采用了os.listdir() 和 fnmatch.fnmatch(). 但是没有真的invoking a subshell.
glob.glob(pathname)
Return a possibly-empty list of path names that match pathname, which must be a string containing a path specification. pathname can be either absolute (like /usr/src/Python-1.5/Makefile) or relative (like ../../Tools/*/*.gif), and can contain shell-style wildcards. Broken symlinks are included in the results (as in the shell).
关键是,支持了symlinks。
glob 模块主要包含了两个方法:
glob.glob
该方法返回所有匹配的文件路径列表,该方法需要一个参数用来指定匹配的路径字符串(本字符串可以为绝对路径也可以为相对路径),其返回的文件名只包括当前目录里的文件名,不包括子文件夹里的文件。