Уведомления

Группа в Telegram: @pythonsu

#1 Окт. 19, 2017 14:23:14

editkukum
Зарегистрирован: 2017-10-19
Сообщения: 2
Репутация: +  0  -
Профиль   Отправить e-mail  

Помощь по zlib

Есть файл с расширением .res и он упакован zlib'ом. Вопрос: как его распаковать?

Офлайн

#2 Окт. 19, 2017 14:28:28

Slow
Зарегистрирован: 2017-07-26
Сообщения: 88
Репутация: +  4  -
Профиль   Отправить e-mail  

Помощь по zlib

https://docs.python.org/3/library/zlib.html
Что ж за идиотские вопросы то?..

Офлайн

#3 Окт. 19, 2017 18:12:21

editkukum
Зарегистрирован: 2017-10-19
Сообщения: 2
Репутация: +  0  -
Профиль   Отправить e-mail  

Помощь по zlib

Slow
https://docs.python.org/3/library/zlib.htmlЧто ж за идиотские вопросы то?..
Я пытаюсь это использовать, но выдаёт исключение:
 Traceback (most recent call last):
  File "C:/Users/Аня/AppData/Local/Programs/Python/Python36-32/Script1.py", line 5, in <module>
    file = zlib.decompress(file)
zlib.error: Error -3 while decompressing data: incorrect header check 

Офлайн

#4 Окт. 19, 2017 18:19:09

Slow
Зарегистрирован: 2017-07-26
Сообщения: 88
Репутация: +  4  -
Профиль   Отправить e-mail  

Помощь по zlib

потому что, судя по ошибке, у вас не zlib, а deflate или gzip

вообще, ответ гуглится довольно быстро -
https://stackoverflow.com/questions/3122145/zlib-error-error-3-while-decompressing-incorrect-header-check
и там английским по белому написано, как с этой ошибкой бороться:

You have this error:

zlib.error: Error -3 while decompressing: incorrect header check
Which is most likely because you are trying to check headers that are not there, e.g. your data follows RFC 1951 (deflate compressed format) rather than RFC 1950 (zlib compressed format) or RFC 1952 (gzip compressed format).

choosing windowBits

But zlib can decompress all those formats:

to (de-)compress deflate format, use wbits = -zlib.MAX_WBITS
to (de-)compress zlib format, use wbits = zlib.MAX_WBITS
to (de-)compress gzip format, use wbits = zlib.MAX_WBITS | 16
See documentation in http://www.zlib.net/manual.html#Advanced (section inflateInit2)
automatic header detection (zlib or gzip)

adding 32 to windowBits will trigger header detection

>>> zlib.decompress(gzip_data, zlib.MAX_WBITS|32)
'test'
>>> zlib.decompress(zlib_data, zlib.MAX_WBITS|32)
'test'

Отредактировано Slow (Окт. 19, 2017 18:21:20)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version