#!/usr/bin/python #encoding:utf-8 import os FileList=[] def ScanFile(Dir,Suffix): if os.path.isdir(Dir): items=os.listdir(Dir) for names in items: if os.path.isfile(Dir+‘/‘+names) and names.endswith(Suffix): FileList.append(Dir+‘/‘+names) else: if os.path.isdir(Dir+‘/‘+names): ScanFile(Dir+‘/‘+names,Suffix) DIRNAME="/tmp" ScanFile(DIRNAME,".log") if len(FileList)!=0: print(FileList) else: print("查找文件不存在")