Python zipfile module ZIP64

Source: Internet
Author: User

Python comes with a zipfile module for reading and writing zip files.

def zip_dir (dirname,zipfilename):    filelist = []    if Os.path.isfile (dirname):        filelist.append (dirname)    else:        for root, dirs, files in Os.walk (dirname): For            name in Files:                filelist.append (Os.path.join (Root , name))             ZF = ZipFile. ZipFile (Zipfilename, "w", ZipFile. zip_stored,allowzip64=true) for    tar in filelist:        arcname = Tar[len (dirname):]        #print arcname        Zf.write (Tar,arcname)    

  

ZF = ZipFile. ZipFile (Zipfilename, "w", ZipFile. Zip_stored,allowzip64=true)
The above function has four functions: The zip file contains the name of the path, "W"/"R" means write or read, ZipFile. Zip_stored represents the storage format (and can also be zipfile.zlib.DEFLATED for a compressed format), allowzip64=true This parameter is used when working with large files, and defaults to false. If not set to True, the zip file size require ZIP64 extensions is prompted when processing large files.

Python zipfile module ZIP64

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.