2014-03-01 34 views
1

如何運行以下行?通過子流程模塊在Python中剪切命令

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

它返回此錯誤:

cut: the delimiter must be a single character 
+0

在這種情況下,你真的需要調用'cut'嗎? – devnull

+0

哦,是的,devnull在說什麼:改用python的split()命令。 –

回答

2

不要雙引號:

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

足夠!

+0

錯誤消息不再出現,但腳本不起作用 –

+0

然後問另一個問題,給我們更多的信息! – hivert

+0

對不起 –