Create Zip File from File List

  • Share this:

Code introduction


Create a zip file from a list of files.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zipfiles(file_list, output_zip):
    import zipfile
    with zipfile.ZipFile(output_zip, 'w') as zipf:
        for file in file_list:
            zipf.write(file)
    return "Zip file created successfully."                
              
Tags: