Create new ZIP file



    Python public recipes

    The code first creates a new ZipFile object and stores the path to the file in the zipfile variable. Then, the code writes the contents of the file.txt file to the new_zip object using the zipfile.ZIP_DEFLATED compression type.

    Shortcut: zipfile.write

    import zipfile
    with zipfile.ZipFile(zipfile, 'w') as new_zip:
      new_zip.write('filetoadd', compress_type=zipfile.ZIP_DEFLATED)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.