I have a zip file structure like - B.zip/org/note.txt I want to directly list the files inside org folder without going to other folders in B.zip
I have written the following code but it is listing all the files and directories available inside the B.zip file
f = zipfile.ZipFile('D:\python\B.jar')
for name in f.namelist():
print '%s: %r' % (name, f.read(name))
You can filter the yields by startwith function.(Using Python 3)
import os
import zipfile
with zipfile.ZipFile('D:\python\B.jar') as z:
for filename in z.namelist():
if filename.startswith("org"):
print(filename)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With