【发布时间】:2018-01-11 08:45:36
【问题描述】:
没有足够的 zstd 压缩示例。我正在使用 zstandard 0.8.1,尝试一次压缩 2 个字节。在使用write_to(fh) 时遇到https://anaconda.org/rolando/zstandard,但不知道如何使用它。下面是我尝试从文件中读取一个chuck字节的部分代码,然后压缩每个chuck,
cctx = zstd.ZstdCompressor(level=4)
使用 open(path, 'rb') 作为 fh:
而真:
bin_data = fh.read(2) #读取 2 个字节
如果不是 bin_data:
休息
压缩 = cctx.compress(bin_data)
fh.close()
with open(path, 'rb') as fh:
with open(outpath, 'wb') as outfile:
outfile.write(compressed)
...
但是我应该如何使用 write_to()?
【问题讨论】:
标签: compression byte zstandard