使用lzw算法的任意文件的压缩程序和解压缩程序

lzw3的Python项目详细描述


使用LZW algorithm的压缩机和减压器 用Python写的。

要求

至少需要Python3.5。

安装

pip install lzw3

用法

两个脚本将安装在本地二进制路径中(例如 /home/user/.local/bin):compressuncompress。如果你愿意 要调用这些脚本,请确保您的$PATH包含python 二进制路径注意,这个压缩程序只压缩常规文件(即 不创建.zip或.tar.gz等存档文件)。不管怎样,目录 仍然可以使用以下选项进行压缩:-r

压缩

压缩阶段用压缩的 一个,附加扩展名“.z”

压缩文件列表:

python3 -m lzw3.compressor doc1.txt doc2.txt

递归压缩目录:

python3 -m lzw3.compressor -r /home/user/Docs/Project

或者,您可以使用compress脚本,如下所示:

compress doc1.txt doc2.txt

选项

-r
    Recursively compress the files inside the directories
    within the given file list.
    If not specified, directories in the file list are skipped.

-v
    Prints information about the handled files and the percentage of
    saved space for each compressed file.

-t
    Prints the time spent for compress each file.

-k
    Keeps the original files instead of replace those with the
    compressed ones.

-f
    Force to compress and keep the compressed file, even if the size
    of the compressed file is higher than the size of the original one.

-d
    Prints debug messages.

减压

解压阶段将替换压缩文件(扩展名为 “.z”)与未压缩的。

解压缩文件列表:

python3 -m lzw3.decompressor doc1.txt.Z doc2.txt.Z

递归解压缩目录:

python3 -m lzw3.decompressor -r /home/user/Docs/Project

或者,您可以使用uncompress脚本,如下所示:

uncompress doc1.txt.Z doc2.txt.Z

选项

-r
    Recursively decompress the files inside the directories
    within the given file list.
    If not specified, directories in the file list are skipped.

-v
    Prints information about the handled files.

-t
    Prints the time spent for decompress each file.

-k
    Keeps the decompressed files after the decompression.

-f
    Force to decompress the files even if the file name
    doesn't end with ".Z".

-d
    Prints debug messages.

测试

这个项目带有很少的单元测试,无论是静态的还是随机的 生成的文件。要运行测试,请使用:

python3 setup.py test

许可证

lzw3是MIT licensed

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java检查时间更长   从文件中只读取一些字符串并将其存储在java的堆栈中   java变量引用与避免空指针的重复get调用   java将xml数据转换为字符串   java在if语句中对字符串中的表达式求值   java找不到符号IllegalArgumentException   java将servlet的返回值从JSP转换为JSON   在eclipse中运行java应用程序与直接运行它有何不同?   如何在java中创建用作密码的随机字符串   java Mojo Codehaus属性插件替代方案   关于Hibernate中Clob对象的java问题   java如何使用websocket范围测试组件?   java在mongodb中将mapreduce查询转换为聚合   EclipseJava远程调试:如何确保项目中的代码与JVM中运行的代码相同?   java初学者Android:ListView影响下一个类   Java swing BasicTextFieldUI绘制问题   当我在操作栏上添加溢出菜单时,java 安卓 Action Up按钮不起作用   java如何将只包含标题(无行)的数据集写入hdfs位置(csv格式),以便在下载时包含标题?