问题
I have the following code in PHP:
$text = gzcompress($text);
// send $text to a python server
Then in python I have the following code:
text = request.POST.get('text', '')
new_text = zlib.decompress(text)
But this fails because the decompress function needs bytes and I am passing it a string. Does anyone know how to decompress a string in python that was compressed in php?
PS: I am not particularly interested in a specific algorithm or function.
来源:https://stackoverflow.com/questions/54151487/compress-string-in-php-and-decompress-in-python