首页 > 移动平台 > 详细

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

时间:2020-03-26 14:14:45      阅读:147      评论:0      收藏:0      [点我收藏+]
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文件

原文:https://www.cnblogs.com/dyc99/p/12574004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!