Python 3.x 如何抑制7zip详细输出,但以百分比表示提取状态?

Python 3.x 如何抑制7zip详细输出,但以百分比表示提取状态?,python-3.x,batch-file,subprocess,7zip,Python 3.x,Batch File,Subprocess,7zip,7zip提取的示例输出如下所示: Scanning the drive for archives: 1 file, 9770776 bytes (9542 KiB) Extracting archive: tools\StrawberryPerl.7.exe -- Path = tools\StrawberryPerl.7.exe Type = 7z Offset = 162816 Physical Size = 9607960 Headers Size = 11687 Method = L

7zip提取的示例输出如下所示:


Scanning the drive for archives:
1 file, 9770776 bytes (9542 KiB)

Extracting archive: tools\StrawberryPerl.7.exe
--
Path = tools\StrawberryPerl.7.exe
Type = 7z
Offset = 162816
Physical Size = 9607960
Headers Size = 11687
Method = LZMA:24m BCJ2
Solid = +
Blocks = 2

 78% 602 - perl\lib\auto\Module\Pluggable\.packlistProcess SpawnPoolWorker-6:
我的问题是,如何抑制此操作以仅获取提取百分比(
78%602-perl\lib\auto\Module\Pluggable\.packlistProcess-worker-6:

我找到了几个关于抑制详细输出的答案,如:

  • >NUL:
    添加到bat命令的末尾,这将完全抑制消息
  • 在Python中将
    subprocess.Popen
    stdout=PIPE
    stderr=PIPE
    一起使用,这再次抑制了所有消息

  • 使用
    findstr/b/r/c:“\尝试使用以下方法管道化输出:

    [7z command] | findstr /rc:"[0-9][%]"