/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
gzip_examples/main.py
35 строк
693 B
gil9red
Refactoring. Using black code style
20 май 2023, 16:44
20 май 2023, 16:44
449e1ea
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import gzip import io from urllib.request import urlopen # From file name with gzip.open("build-kernel.xml.gz") as f: file_content = f.read() print(file_content) # From bytes / memory file bytes_data = open("build-kernel.xml.gz", mode="rb").read() byte_io = io.BytesIO(bytes_data) with gzip.open(byte_io) as f: file_content = f.read() print(file_content) # From url as bytes / memory file with urlopen("http://httpbin.org/gzip") as rs: bytes_data = rs.read() byte_io = io.BytesIO(bytes_data) with gzip.open(byte_io) as f: file_content = f.read() print(file_content)