使用这个python模块zstd 0.8.1仍然是非常新的。我对以下内容进行了测试,
import zstd
cctx = zstd.ZstdCompressor()
zstd_data = cctx.compress(b'aaaaa')
len(zstd_data)
Out[34]: 14 #this is my output但是当我这么做的时候,
cobj = cctx.compressobj()
zstd_data = cobj.compress(b'aaaaa')
len(zstd_data)
Out[39]: 0 #why the length is 0?我的错误是什么?
发布于 2018-10-15 10:58:55
我知道这已经有一段时间了,但我想我会回答任何在谷歌上看到这个页面的人。
看起来您正在使用python-zstandard库(https://github.com/indygreg/python-zstandard/issues)。需要注意的是,在示例中,ZstdCompressor对象演示的最后一行使用了zstd_data = cobj.flush()。添加这一行之后,它应该可以工作了。
或者,如果您更喜欢simple API
cctx = zstd.ZstdCompressor()
compressed = cctx.compress(b'data to compress')第二个示例不包括compressobj()所需的flush()步骤
https://stackoverflow.com/questions/49003055
复制相似问题