Форум сайта python.su
Есть файл с расширением .res и он упакован zlib'ом. Вопрос: как его распаковать?
Офлайн
https://docs.python.org/3/library/zlib.html
Что ж за идиотские вопросы то?..
Офлайн
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
Офлайн
потому что, судя по ошибке, у вас не 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)
Офлайн