python遍历某个文件夹所有子文件夹
来着网络,记录
import os path = r'D:\API_AUTO\API_AUTO\test_result' def get_filelist(): Filelist = [] for home, dirs, files in os.walk(path): for filename in files: # 文件名列表,包含完整路径 Filelist.append(os.path.join(home, filename)) # # 文件名列表,只包含文件名 # Filelist.append( filename) return Filelist if __name__ == "__main__": Filelist = get_filelist() print(len(Filelist)) for file in Filelist: print(file)
要快乐,要有梦想,要自信