【发布时间】:2019-09-13 17:37:15
【问题描述】:
我需要在 shell 命令之上使用 python 压缩大小超过 10 GB 的文件,因此决定使用子进程 Popen。
这是我的代码:
outputdir = '/mnt/json/output/'
inp_cmd='gzip -r ' + outputdir
pipe = Popen(["bash"], stdout =PIPE,stdin=PIPE,stderr=PIPE)
cmd = bytes(inp_cmd.encode('utf8'))
stdout_data,stderr_data = pipe.communicate(input=cmd)
它不是对输出目录中的文件进行 gzip 压缩。 有什么办法吗?
【问题讨论】:
标签: python unix subprocess gzip popen