python解压后缀名为python7z的压缩包控制台实时显示进度解压到CUsersAdministratorAppDataLocalProgramsPython完整pythoon代码
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("解压完成"
原文地址: https://www.cveoy.top/t/topic/fuWY 著作权归作者所有。请勿转载和采集!