Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Create ZIPfile using python

I am trying to create zipfile using python 3.4. Upon execution following error is shown:

AttributeError: 'module' object has no attribute 'Zipfile'

My code:

import zipfile

f= zipfile.Zipfile("testZIP.zip","w")
like image 904
user3832232 Avatar asked Jul 12 '14 12:07

user3832232


People also ask

How do I create an archive in Python?

Create a zip archive from multiple files in PythonCreate a ZipFile object by passing the new file name and mode as 'w' (write mode). It will create a new zip file and open it within ZipFile object. Call write() function on ZipFile object to add the files in it. call close() on ZipFile object to Close the zip file.

How do I create an empty ZIP file in Python?

empty_zip_data is the data of an empty zip file. For Python 3 use empty_zip_data = b'PK\x05... .

What is ZIP file in Python?

Python's zipfile is a standard library module intended to manipulate ZIP files. This file format is a widely adopted industry standard when it comes to archiving and compressing digital data. You can use it to package together several related files.


1 Answers

It is zipfile.ZipFile with a capital F not zipfile.Zipfile

like image 120
Padraic Cunningham Avatar answered Sep 17 '22 04:09

Padraic Cunningham