Python
语言获取目录下所有文件或目录的方法
#! /usr/bin/python'''Utilities of file &
directories.'''import os# Get the all files & directories in the
specified directory (path).def get_recursive_file_list(path):
current_files = os.listdir(path)
all_files = []
for
file_name in current_files:
full_file_name =
os.path.join(path, file_name)
all_files.append(full_file_name)
if
os.path.isdir(full_file_name):
next_level_files =
get_recursive_file_list(full_file_name)
all_files.extend(next_level_files)
return all_files