Python实现压缩解压缩,移动复制copy文件

import shutil
import os
from shutil import make_archive


# 查看可压缩的文件类型
print(shutil.get_archive_formats())
# 压缩文件原始与压缩文件存放的根目录
rootPath = rF:/BaiduNetdiskDownload/COVID-19CTSeg/3DUNet-Pytorch/test
# 压缩文件存放目录
# Myarchive:压缩文件名
# archive_name = os.path.expanduser(os.path.join(rootPath, ‘Myarchive‘))
# # 被压缩文件路径
# root_dir = os.path.expanduser(os.path.join(rootPath, ‘‘))
# make_archive(archive_name, ‘gztar‘, root_dir)

# copyfile
from shutil import copyfile
from shutil import copytree
import logging

def _logpath(path, names):
    logging.info(Working in %s, path)
    return []   # nothing will be ignored
source = rF:/BaiduNetdiskDownload/COVID-19CTSeg/3DUNet-Pytorch/label
destination = rF:/BaiduNetdiskDownload/COVID-19CTSeg/3DUNet-Pytorch/test
copytree(source, destination, ignore=_logpath)

# https://docs.python.org/3/library/shutil.html?highlight=copyfile#shutil-platform-dependent-efficient-copy-operations

Python实现压缩解压缩,移动复制copy文件

上一篇:华为手机突然出现"HD"图标,用了这么久手机你知道什么意思吗?


下一篇:iOS 穿山甲激励视频不展示