Python程序教程

您现在的位置是:首页 >  Python

当前栏目

Python 创建加密压缩文件「建议收藏」

Python,创建,加密,压缩文件,建议,收藏
2025-03-25 08:59:31 时间

大家好,又见面了,我是你们的朋友全栈君。

Python 创建加密压缩文件

1. 配置ZLib

http://www.winimage.com/zLibDll/minizip.html

下载之后将 zlibwapi.dll 放在 demo/目录下,与 minizip.exe 一起使用

2. 命令行使用 minizip.exe

> minizip.exe

MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant
more info at http://www.winimage.com/zLibDll/unzip.html

Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]

  -o  Overwrite existing file.zip
  -a  Append to existing file.zip
  -0  Store only
  -1  Compress faster
  -9  Compress better

3. 配置相关路径,使用python实现

miniZip_path = "youur_path"

def createEncryptedFile(password,zipfile_path,source_path):
    cmd = "{} -o -1 -p {} {} {}".format(miniZip_path,password,zipfile_path,source_path)
    os.system(cmd)
    print(cmd)

测试无误,批处理来一波~~~

4. 同理使用 miniunz.exe 实现解压文件

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/145105.html原文链接:https://javaforall.cn