Python 7-Zip 封装库,支持 ZIP/RAR/7Z 解压、密码处理、文件过滤,跨平台自动安装。
pip install libacg-7zip
要求:Python >= 3.14,支持 Windows/Linux/macOS
from libacg_7zip import Lib7Zip
lib7z = Lib7Zip()
# 基础解压
lib7z.extract("archive.zip", "output_dir")
# 带密码解压
lib7z.extract("encrypted.7z", "output", password="secret")
# 文件过滤
lib7z.extract("archive.zip", "output", include=["*.txt", "*.md"])
# 统计文件数量
files, folders = lib7z.check_filecounts("archive.rar")
| 特性 | 说明 |
|---|---|
| 多格式支持 | ZIP、RAR、7Z 解压与文件统计 |
| 密码处理 | 支持加密压缩包解压 |
| 文件过滤 | include/exclude 模式精确控制 |
| 自动安装 | 检测并自动下载 7-Zip |
| 跨平台 | Windows/Linux/macOS,amd64/arm |
Lib7Zip(
password="...", # 默认密码
include=["*.txt"], # 包含文件
exclude=["*.log"], # 排除文件
recursive_include=True, # 递归匹配
overwrite_mode="-aoa", # 覆盖模式: -aoa/-aos/-aou/-aot
)
ExtToolNotFound - 未找到 7-ZipExtToolError - 执行失败DownloadError - 下载失败ExtractError - 解压失败参见 LibACG 贡献指南。
MIT License