python 遍历文件夹 os.walk(path):
用os包还是什么包?
def getFilelist(self,path): dirResult = {} Filelist = [] FileNamelist = [] for home, dirs, files in os.walk(path): for filename in files: # 文件名列表,包含完整路径 FileNamelist.append(filename) Filelist.append(os.path.join(home, filename)) r = natsorted(Filelist) f = natsorted(FileNamelist) FileTime = [] for n in f:#n is name t = self.fileNameToTime(n)# t is time FileTime.append(t) self.teLog.append(n + ' ---> ' + str(t)) # print(n) dirResult['FileNamelist'] = f dirResult['Filelist'] = r return dirResult