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()
    
  • 相关阅读:
    PKU1008
    PKU 1007
    PKU 3983
    PKU 1005
    PKU1004
    PKU 1003解题
    new.target
    debugger 关键字
    React 高阶组件
    CSS|规范
  • 原文地址:https://www.cnblogs.com/netflix/p/14855188.html
Copyright © 2011-2022 走看看