zoukankan      html  css  js  c++  java
  • 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()
    
  • 相关阅读:
    jedis 连接 虚拟机内redis服务
    数据库存储过程项目总结
    前端jsp联系项目相关经验
    学习做项目的一些随笔
    循环
    字典
    集合
    元组
    列表
    字符串
  • 原文地址:https://www.cnblogs.com/netflix/p/14855188.html
Copyright © 2011-2022 走看看