通过子进程模块在Python中剪切命令

时间:2014-03-01 14:33:04

标签: python subprocess cut

如何运行以下行?

subprocess.Popen(('cut', '-d', '" "', '-f', '1'), stdin=out_2.stdout, stdout=subprocess.PIPE)

它返回此错误:

cut: the delimiter must be a single character

1 个答案:

答案 0 :(得分:2)

不要双引号:

subprocess.Popen(('cut', '-d', ' ', '-f', '1'), stdin=out_2.stdout, stdout=subprocess.PIPE)
                               ^^^

就足够了!