# 将源文件夹下的所有文件复制到目标文件夹中,并将后缀名改为指定名 defcopy_rename_file(src_folder, dest_folder, src_ext, dest_ext): for filename in os.listdir(src_folder): if filename.endswith(src_ext): new_name = os.path.splitext(filename)[0] + dest_ext # 构建新文件名 shutil.move(os.path.join(src_folder, filename), os.path.join(dest_folder, new_name)) # 剪切文件到目标文件夹 print(f"File {filename} has been copied and renamed to {new_name}")