Zipfile module error: File is not a zip file
<p>As of 2.7, zipfile supports <code>with</code>-style context handler, making for much more elegant idiom, where you can't ever forget the implicit <code>close()</code></p>

<p>By the way, don't ever name a local variable something like <code>file</code> which is likely to shadow globals and give very weird debugging behavior.</p>

<p>So, something like:</p>

<pre><code>import zipfile,os,glob

with zipfile.ZipFile("Apap.zip", "w") as f:    
    for name in glob.glob("C:\Users/*"):
        print name
        f.write(name,os.path.basename(name),zipfile.ZIP_DEFLATED)
# `with` causes an implicit f.close() here due to its `exit()` clause

with zipfile.ZipFile("Apap.zip", "r") as f:
    for info in f.infolist():
        print info.filename, info.date_time, info.file_size, info.compress_size
</code></pre>
