Python复制文件到另一个文件下

import os
import shutil

root_path = 'F:\\template_files'
label_path = 'F:\\template\\handobj-mark\\data\\img'
copy_path = 'F:\\02_Porject_GR_Data\\02_Tidy_Data\\QD_Data_0726\\Left_hand\Allen'

def copy_files(path1,path2):
    label_files = os.listdir(path1)
    for label_file in label_files:
        (name,extension) = os.path.splitext(label_file)
        if extension == '.txt':
            textfile_path = os.path.join(path1,label_file)
            shutil.copy(textfile_path,path2)

copy_files(label_path,copy_path)

猜你喜欢

转载自blog.csdn.net/Blackrosetian/article/details/81234654