python findAllfile
import os def findAllfile(path, allfile): filelist = os.listdir(path) for filename in filelist: filepath = os.path.join(path, filename) # print(filepath) if os.path.isdir(filepath): # print(filepath) findAllfile(filepath, allfile) else: allfile.append(filepath) #有目录路径 # allfile = allfile + "/" + filepath # allfile.append(filename) #去掉目录路径 return allfile inputpath = r"D:\Users" filelist = [] filelist = findAllfile(inputpath, filelist)#find all file for filesrc in filelist: print(filesrc)