Python文件查找

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/python

import os
import string

def get_name(path_name, file_str):
        dir_name = []
        dir_name = os.listdir(path_name)
        for i in range(0, len(dir_name)):
                curdir = os.path.join(path_name, dir_name[i])
                if os.path.isdir(curdir):
                        if file_str in dir_name[i]:
                                print 'DIR:' + curdir
                        get_name(curdir, file_str)
                else:
                        if file_str in dir_name[i]:
                                print 'FILE:' + curdir


file_name = raw_input("Input file name:")
path = raw_input("Input path:")

get_name(path, file_name)