其他分享
首页 > 其他分享> > day05_05 shutil模块进行压缩

day05_05 shutil模块进行压缩

作者:互联网

__author__ = "Alex Li"

import shutil

f1 = open("本节笔记",encoding="utf-8")

f2 = open("笔记2","w",encoding="utf-8")
shutil.copyfileobj(f1,f2)

shutil.copyfile("笔记2","笔记3")
shutil.copystat("本节笔记","笔记3")

#copy文件夹和目录
# shutil.copytree("test4","new_test4")
# shutil.rmtree("new_test4")

#创建压缩包并返回文件路径
# shutil.make_archive("shutil_archive_test", "zip","E:\python S14\day5\day5-atm")


#shutil 对压缩包的处理是调用 ZipFile 和 TarFile 两个模块来进行的,详细
import zipfile

z = zipfile.ZipFile("day5.zip","w")

z.write("p_test.py")
print("-----")
z.write("笔记2")

z.close()

标签:__,f1,test4,05,day5,笔记,day05,shutil
来源: https://www.cnblogs.com/netflix/p/14855188.html