def get_members(zip):
    parts = []
for name in zip.namelist():
    if not name.endswith('/'):
        parts.append(name.split('/')[:-1])
prefix = os.path.commonprefix(parts)
if prefix:
    prefix = '/'.join(prefix) + '/'
offset = len(prefix)
for zipinfo in zip.infolist():
    pass
Extract files from zip without keep the top-level folder with python zipfile