python:复制文件夹及内容(包含子文件夹)到指定目录

import yaml
import os
import shutil


def copyHistorySession():
    source_path5048 = r'D:\sourse'
    target_path5048 = r'D:\target'
    if not os.path.exists(target_path5048):
        # 如果⽬标路径不存在原⽂件夹的话就创建
        os.makedirs(target_path5048)
    if os.path.exists(source_path5048):
        # 如果⽬标路径存在原⽂件夹的话就先删除
        shutil.rmtree(target_path5048)
    shutil.copytree(source_path5048, target_path5048)
    print('copy 5048 History Session finished!')

猜你喜欢

转载自blog.csdn.net/zhangliang0000/article/details/127492996