Listing all directories recursively within the zipfile without extracting in python
<p>In Python we can get the list of all files within a zipfile without extracting the zip file using the below code.</p>

<pre><code>import zipfile
zip_ref = zipfile.ZipFile(zipfilepath, 'r')
    for file in zip_ref.namelist():
        print file
</code></pre>

<p>Similarly is there a way to fetch the list of all directories and sub directories within the zipfile without extracting the zipfile?</p>

<pre><code>import zipfile

with zipfile.ZipFile(zipfilepath, 'r') as myzip:
   print(myzip.printdir())
</code></pre>

python file directory zipfile filestructure