Python 使用 tqdm 解压 7z 文件到 C 盘
您可以使用以下代码使用 Python 和 tqdm 库解压 7z 压缩文件到 C 盘,并显示进度条:
import os
from tqdm import tqdm
import py7zr
archive_path = 'path/to/archive.7z'
extract_path = 'C:\'
with py7zr.SevenZipFile(archive_path, 'r') as archive:
members = archive.getnames()
with tqdm(total=len(members), desc='Extracting') as pbar:
for member in members:
archive.extract(member, path=extract_path)
pbar.update(1)
print('Extraction complete!')
请注意,您需要安装 py7zr 和 tqdm 模块。您可以使用以下命令安装它们:
pip install py7zr tqdm
原文地址: https://www.cveoy.top/t/topic/oihR 著作权归作者所有。请勿转载和采集!