擅长:python、mysql、java
<p>只需使用<a href="http://docs.python.org/library/os.html#os.walk" rel="nofollow">^{<cd1>}</a>并过滤它。在</p>
<pre><code>import os
def p4glob(ext, startdir='.'):
for root, dirs, files in os.walk(startdir):
for f in files:
# whatever filter params you need. e.g:
if f.endswith(ext):
yield os.path.join(root, f)
# or append to an output list if you dont want a generator
# usage
[i for i in p4glob(".xml")]
</code></pre>