python复制文件夹下所有子文件以及子文件夹下的文件到指定目录
import os
import shutildef extract_files(source_folder, destination_folder):if not os.path.exists(destination_folder):os.makedirs(destination_folder)for root, dirs, files in os.walk(source_folder):for file in files:source_path = os.path.join(root, file)destination_path = os.path.join(destination_folder, file)shutil.copy2(source_path, destination_path)# 使用示例
source_folder = 'C:/Users/whz/Downloads/Compressed/【362首伍佰合集】(1992-2020)/test' # 源文件夹路径
destination_folder = 'path/to/destination/folder' # 目标文件夹路径
extract_files(source_folder, destination_folder)
~~~ python