如何運行以下行?通過子流程模塊在Python中剪切命令
subprocess.Popen(('cut', '-d', '" "', '-f', '1'), stdin=out_2.stdout, stdout=subprocess.PIPE)
它返回此錯誤:
cut: the delimiter must be a single character
如何運行以下行?通過子流程模塊在Python中剪切命令
subprocess.Popen(('cut', '-d', '" "', '-f', '1'), stdin=out_2.stdout, stdout=subprocess.PIPE)
它返回此錯誤:
cut: the delimiter must be a single character
不要雙引號:
subprocess.Popen(('cut', '-d', ' ', '-f', '1'), stdin=out_2.stdout, stdout=subprocess.PIPE)
^^^
足夠!
在這種情況下,你真的需要調用'cut'嗎? – devnull
哦,是的,devnull在說什麼:改用python的split()命令。 –