【问题标题】:Translating ActionScript3's ByteArray uncompress() to Python 3将 ActionScript3 的 ByteArray uncompress() 转换为 Python 3
【发布时间】:2020-04-29 06:04:05
【问题描述】:

我在 ActionScript3 中创建了以下示例代码来对字符串进行放气解压缩:

    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 中复制代码 sn-p。我曾尝试使用 Py3AMF 库,但是我没有看到进行 deflate uncompress 的方法。

谢谢!

【问题讨论】:

标签: python-3.x actionscript-3 zlib deflate


【解决方案1】:

解决了!解决方案是使用

-zlib.MAX_WBITS

这是 Python 3 中的代码 sn-p:

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

【讨论】:

  • 感谢解决它并分享解决方案。
猜你喜欢
  • 1970-01-01
  • 2010-10-28
  • 1970-01-01
  • 1970-01-01
  • 2014-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多