“静默"提取 7-Zip 文件- 命令行选项 [英] Extracting a 7-Zip file "silently" - command line option
问题描述
我想在 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屋!