</pre><pre name="code" class="python">
</pre><pre name="code" class="python">
</pre><pre name="code" class="python">
简单的使用python遍历目录函数:
def run(path):
for path, dirs, files in os.walk(path):
#do your work
if not files:
continue
olddir = os.getcwd()
os.chdir(path)
#print os.getcwd()
for f in files:
r = fnre.search(f)
if not r:
continue
record = parseFile()
orderid = r.group(1)
st = os.stat(f)
ut = st.st_ctime
print f, orderid, time.localtime(ut)
break
os.chdir(olddir)