def take(source_dir, destination_dir):
# 确保目标文件夹存在,如果不存在则创建
if not os.path.exists(destination_dir):
os.makedirs(destination_dir)
# 遍历源文件夹中的所有文件
for filename in os.listdir(source_dir):
# 检查文件扩展名是否为.json
if filename.endswith('.png'):
# 构建完整的文件路径
source_file = os.path.join(source_dir, filename)
destination_file = os.path.join(destination_dir, filename)
# 复制文件
shutil.copy(source_file, destination_file)
print(f"Copied {filename} to {destination_dir}")