Create and Add File to Zip

  • Share this:

Code introduction


This function creates a zip file and adds a specified file to the zip file.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zipfile(arg1, arg2):
    import zipfile
    with zipfile.ZipFile(arg1, 'w') as zipf:
        zipf.write(arg2, arcname='example.txt')
    return zipfile.ZipFile(arg1)                
              
Tags: