day05_05 shutil模块进行压缩

Posted flytoyou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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()

以上是关于day05_05 shutil模块进行压缩的主要内容,如果未能解决你的问题,请参考以下文章

day5模块学习--shutil模块

python之路:Day05 --- 常用模块

day5-shutil模块

python学习笔记-Day7(configparser模块shutil压缩与解压模块subprocess)

Python函数和常用模块day06:shutil-shelve-xml-configparser模块

day05