title: Python: Zipping a Folder + File
body: <p>I have a folder structure like this: C:\Users\Simon\Desktop\mySoftware\files\output\</p>
  
  <p>In the output folder, there is a file and a folder with another file in.</p>
  
  <p>I need Python to compress the files (and the folder) inside the 'output' folder.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>#!/usr/bin/env python
  import os, zipfile
  
  simonsFiles = 'C:\Users\Simon\Desktop\mySoftware\files\output\\'
  
  simonsZip = zipfile.ZipFile("myzipfile.zip", "w")
  for dirname, subdirs, files in os.walk(simonsFiles):
      simonsZip.write(dirname)
      for filename in files:
          simonsZip.write(os.path.join(dirname, filename))
  simonsZip.close()
  </code></pre>
  
  <p>But Python creates a zip folder in with the entire structure:</p>
  
  <p>Users\Simon\Desktop\mySoftware\files\output\</p>
  
  <p>and when I get to output, it has the folder and the file that I wanted to compress to zip.</p>
  
  <p>How can I make Python compress the folder and the file into a zip rather than the entire directory structure?</p>