根据关键字查找文件

根据关键字查找文件

import os
def getfile(path,word):
    for filename in os.listdir(path):
        file = os.path.join(path,filename)
        if os.path.isfile(file) and word in filename:
            print file
        elif os.path.isdir(file):
            getfile(file,word)
if __name__ == '__main__':
    getfile(path,word)

猜你喜欢

转载自blog.csdn.net/weixin_42934547/article/details/81565255