受到上一篇博客的启发,对它进行了少量的修改,就可以用它来进行文件的查找
#-*- coding:utf-8 -*-
import time
import os
import re
flag = 0
def findfile(filename,path):
for root,dirs,files in os.walk(path):
for file in files:
if file == filename:
print os.path.join(root,file)
print "Matched!"
flag = 1
break
if flag == 0:
print "None Matched"
src = r'19 - 1 - Summary and Thank You (5 min).mp4'
dest = r'F:'
start = time.time()
findfile(src,dest)
c = time.time()-start
print ("%0.2f s"%c)
我觉得搜索的还蛮快的,虽然说效率肯定不高。