Decided: How in Python 3 encode file, for open this file with PHP zlib_decode function?-ThrowExceptions

Exception or error:

I found a fix, must use wb+ option for save binary files and dont use str()

Code in PHP that i cant change:

$s_st = unserialize(zlib_decode($s_st));

I try this Python code:

import zlib
from phpserialize import serialize

file = zlib.compress(serialize(data), 9)

with open('data.pak', 'w+') as f_out:

But PHP cant open this file.
I also install PHP to check what file create zlib_encode (zlib_encode(serialize($data),15)) with same data, and these files are different.

Python file starts from:


Looks like file content in bytes

PHP file starts from:

њҐќ[Ом(і¦ЇіҐћDЯ—dО°{X=©‰ њ пЗRХ_»цЄ§Н1€гяыw]!‡ящ?ЖеЏsсъ„l?—фЧяю_ќuз!Фz¤СЙ`\ши

So my question is: How create file in Python, that I can then open in PHP, using code at the beginning.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *