情景如下:提取result文件夹下的除".txt"文件



最终效果:

# coding=UTF-8
import os
import shutil
def get_file(root_path,all_files=[]):
'''
递归函数,遍历该文档目录和子目录下的所有文件,获取其path
'''
files = os.listdir(root_path)
for file in files:
if os.path.isdir(root_path + '\\' + file): # not a dir
list_name.append(file)
if file== '

本文介绍如何使用Python遍历指定目录及其子目录,查找并复制非.txt文件,将它们保留在对应的目录结构中。
最低0.47元/天 解锁文章
5775

被折叠的 条评论
为什么被折叠?



