首页 > 技术文章 > 脚本-获取文件夹下所有文件

xiao-xue-di 2019-10-22 16:31 原文

# 获取文件夹下所有文件

# _*_ coding: utf-8 _*_ import os path = r'E:\log' 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

 

推荐阅读