I have a zip file with a folder in it, like this:
some.zip/
some_folder/
some.xml
...
I am using the zipfile
library.
What I want is to open only some.xml file, but I don't now the some_folder name.
My solution looks like this:
def get_xml(zip_file):
for filename in zip_file.namelist():
if filename.endswith('some.xml'):
return zip_file.open(filename)
I would like to know if there is a better solution other than scanning the entire list.