I\'m trying to extract a specific file from a zip archive using python.
In this case, extract an apk\'s icon from the apk itself.
I am currently using
<You can use zipfile.ZipFile.open:
import shutil
import zipfile
with zipfile.ZipFile('/path/to/my_file.apk') as z:
with z.open('/res/drawable/icon.png') as zf, open('temp/icon.png', 'wb') as f:
shutil.copyfileobj(zf, f)
Or use zipfile.ZipFile.read:
import zipfile
with zipfile.ZipFile('/path/to/my_file.apk') as z:
with open('temp/icon.png', 'wb') as f:
f.write(z.read('/res/drawable/icon.png'))