Created
October 30, 2020 15:47
-
-
Save amacal/aa9493c0a5180c500b885b4ff565b8d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zipfile import ZipFile, Path | |
with ZipFile('python-3.9.0-docs-pdf-a4.zip') as archive: | |
# extract everything | |
archive.extractall() | |
# just one file | |
archive.extract('docs-pdf/faq.pdf', 'docs') | |
# pathlike way | |
root = Path(archive) | |
faq = root / 'docs-pdf' / 'faq.pdf' | |
# read them directly | |
data = faq.read_bytes()[0:4] | |
assert data == b'%PDF' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment