import os import subprocess

压缩包路径

zip_path = 'D:/test/python.7z'

解压路径

extract_path = 'C:/Users/Administrator/AppData/Local/Programs/Python/'

解压命令

cmd = f'7z x {zip_path} -o{extract_path} -y'

执行命令

process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

实时显示解压进度

while True: output = process.stdout.readline().decode() if output == '' and process.poll() is not None: break if output: print(output.strip())

输出解压结果

print('解压完成')

Python 解压 .7z 压缩包并实时显示进度

原文地址: https://www.cveoy.top/t/topic/oifQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录