zoukankan      html  css  js  c++  java
  • Python

    # 导入压缩模块
    import zipfile
    # 查看当前模块的功能
    # help(zipfile)
    '''
    a.打开冰箱门(创建压缩文件,并且打开)
        方法:z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True)
            参数
                    file:压缩文件的路径
                    mode="r":设置操作文件的模式  r 读取  w 写入  a 追加模块 x 抑或模式
                    compression:设置压缩模式
                                ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),
                                ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma).                
                    allowZip64:设置压缩文件是否超过2个G
    '''
    zp = zipfile.ZipFile('./zip01.zip', 'w')
    '''
    b.把大象塞进去(把文件添加到压缩文件当中)
        方法: write(self, filename, arcname=None, compress_type=None)
            参数
                    filename:需要添加的文件
                    arcname:在压缩文件中的路径和名称 
    '''
    zp.write('./递归.py', 'm.py')
    '''
    c.把冰箱门关上(关闭压缩文件)
    '''
    zp.close()
  • 相关阅读:
    希望jQuery操作DOM文档,则必须确保DOM载入后开始执行
    Web全栈AngularJS
    Web全栈AngularJS
    Web全栈AngularJS
    KD-Tree
    KD-Tree
    KD-Tree
    KD-Tree
    如何提升自身实力
    如何提升自身实力
  • 原文地址:https://www.cnblogs.com/cxstudypython/p/11992438.html
Copyright © 2011-2022 走看看