Create Zip File from Specified File

  • Share this:

Code introduction


Create a zip file containing a specified file.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zipfile_create(input_file, output_file):
    import zipfile
    with zipfile.ZipFile(output_file, 'w') as zipf:
        zipf.write(input_file, arcname=input_file)
    return output_file                
              
Tags: