glob — Unix style pathname pattern expansion

unix 格式的路径匹配模块

glob.glob(pathname)

>>> glob.glob('/Users/haofei/downloads/mypython/*.py')
['/Users/dd/downloads/python/Autologin.py', '/Users/dd/downloads/python/clea.py', '/Users/dd/downloads/python/get.py', '/Users/dd/downloads/python/multy.py', '/Users/dd/downloads/python/sbug.py', '/Users/dd/downloads/python/Sargv.py', '/Users/dd/downloads/python/bug.py', '/Users/dd/downloads/python/xieng.py']

 

glob.iglob(pathname)

 1 >>> glob.iglob('/Users/haofei/downloads/mypython/*.py')
 2 <generator object iglob at 0x102888d20>
 3 >>> p=glob.glob('/Users/haofei/downloads/mypython/*.py')
 4 >>> for i in p:
 5 ...     print i
 6 ... 
 7 /Users/dd/downloads/python/login.py
 8 /Users/dd/downloads/python/clean_data.py
 9 /Users/dd/downloads/python/img2.py
10 /Users/dd/downloads/python/multy.py
11 /Users/dd/downloads/python/bug.py
12 /Users/dd/downloads/python/argv.py
13 /Users/dd/downloads/python/bug.py
14 /Users/dd/downloads/python/cheng.py