python 模糊找文件例子

import os

def search_file(path,keyword):
for cur_path,dirs,files in os.walk(path):
for file_name in files: #xx.mp4
if keyword in file_name:
abs_path = os.path.join(cur_path,file_name)
print("查找到 %s,绝对路径是 %s" % (file_name,abs_path))



search_file("/Users/dj/work/python/automation/fmz_code/day5/作业/",".log")






posted @ 2021-05-16 23:17  candy耶  阅读(397)  评论(0)    收藏  举报