Compress string in php and decompress in python

心已入冬 提交于 2020-12-13 03:12:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!