文件查找

import os


def detect_walk(dir_path,name):
    for root, dirs, files in os.walk(dir_path):
        for file_name in files:
            if name in file_name:
                print('在--{}--中找到'.format(root))
        for dir_name in dirs:
            if name in dir_name:
                print('在--{}--中找到'.format(root))


if __name__ == "__main__":
    detect_walk('/', 'python')

 

posted @ 2018-06-17 09:31  孤寂之地  阅读(118)  评论(0)    收藏  举报