title: Getting an Error while encountering a non Zip file
body: <p>I wanted to get the comment data of Zip files from an entire folder, but when ever it encounters any other file besides a Zip file it gives me an error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "C:\Users\user\Desktop\New
    folder\ec5.py", line 11, in 
        with ZipFile(zfile, 'r') as testzip:   File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py",
    line 1200, in <strong>init</strong>
        self._RealGetContents()   File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py",
    line 1267, in _RealGetContents
        raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file</p>
  </blockquote>
  
  <p>Is it possible to fix it useing anything along the lines of:</p>
  
  <pre><code>try:
  
  exception
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>import os
  
  import unicodedata
  
  from zipfile import ZipFile
  rootFolder = u"C:/Users/user/Desktop/archives/"
  
  zipfiles = [os.path.join(rootFolder, f) for f in os.listdir(rootFolder)]
  for zfile in zipfiles:
      print("Opening: {}".format(zfile))
      with ZipFile(zfile, 'r') as testzip:
          print(testzip.comment) # comment for entire zip
          l = testzip.infolist() #list all files in archive
          for finfo in l:
              # per file/directory comments
              print("{}:{}".format(finfo.filename, finfo.comment))
  </code></pre>