将ActionScript3的ByteArray uncompress()转换为Python 3

问题描述 投票:0回答:1

我已经在ActionScript3中创建了以下示例代码以对字符串进行deflate-uncompress:

    var byteArray = new ByteArray();
    byteArray.position = 0;
    byteArray.writeUTF("stackoverflow");
    byteArray.compress("deflate");
    trace("Compressed: " + byteArray.toString());
    byteArray.uncompress("deflate");
    trace("Uncompressed: " + byteArray.toString());

似乎ActionScript3稍微修改了RFC1951以删除标头。目前,我无法在Python 3中复制代码段。我尝试使用Py3AMF库,但是我没有看到进行放气解压缩的方法。

谢谢!

python-3.x actionscript-3 zlib deflate
1个回答
0
投票

解决了!解决方法是使用

-zlib.MAX_WBITS

这是Python 3中的代码段:

f = open("decode.txt", "rb")
data = f.readline()
print(data)
print((zlib.decompress(data, -zlib.MAX_WBITS)).decode("utf-8"))

好吧???

© www.soinside.com 2019 - 2024. All rights reserved.