且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Python解压缩.Z文件

更新时间:2021-11-26 22:44:19

Python在模块中没有等效的Unix uncompress,这是您需要解压缩的。 Z文件。您可能需要a)外壳到Unix compress命令,b)外壳到gzip,c)外壳到7-zip(gzip和7-zip都具有解压缩.Z文件的能力),d)修改在C中原始的解压缩代码并链接到Python(该代码可在线获得),或者e)在本机Python中编写自己的LZW解压缩器。

Python does not have the equivalent of Unix uncompress available in a module, which is what you'd need to decompress a .Z file. You would either need to a) shell out to the Unix compress command, b) shell out to gzip, c) shell out to 7-zip (both gzip and 7-zip have the ability to decompress .Z files), d) modify the original uncompress code in C and link that to Python (the code is available online), or e) write your own LZW decompressor in native Python.

对于d),您可以在mathematica.stackexchange.com 上的答案中找到我编写的一些C代码来。请参见 unlzw()函数。

For d), you can find some C code I wrote to do this job in this answer on mathematica.stackexchange.com. See the unlzw() function.