“静默地”提取7-Zip文件。 -命令行选项 [英] Extracting a 7-Zip file "silently" - command line option

查看:106
本文介绍了“静默地”提取7-Zip文件。 -命令行选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Python脚本中提取 7-Zip 存档。效果很好,只是它会吐出提取细节(在我的情况下这是很大的)。

I want to extract a 7-Zip archive in a Python script. It works fine except that it spits out the extraction details (which is huge in my case).

在提取过程中是否有避免这种冗长信息的方法?我没有找到 7z.exe 的任何静默命令行选项。

Is there a way to avoid this verbose information while extracting? I did not find any "silent" command line option to 7z.exe.

我的命令是

7z.exe -o some_dir x some_archive.7z


推荐答案

一种可能是使用 popen ,因此其输出将返回到父级进行处理/显示(如果需要),或者完全忽略(创建)您的 popen 对象,其中包含 stdout = PIPE stderr = PIPE 以便能够从孩子那里检索输出。

One possibility would be to spawn the child process with popen, so its output will come back to the parent to be processed/displayed (if desired) or else completely ignored (create your popen object with stdout=PIPE and stderr=PIPE to be able to retrieve the output from the child).

这篇关于“静默地”提取7-Zip文件。 -命令行选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆