Python子进程在使用unix连接命令时抛出错误

问题描述 投票:0回答:1

我正在尝试使用子进程对2个文件进行排序后将它们结合在一起。但是我收到以下错误。尝试转义'/',也没有帮助。

cmd = "join --nocheck-order -t/: <(sort file1) <(sort file2)"
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shellresult = proc.communicate()
print result

('', '/bin/sh: 1: Syntax error: "(" unexpected\n')
python unix subprocess
1个回答
0
投票

您在使用<(sort file)语法时遇到问题。尝试在Popen()中使用shell = True

参数
© www.soinside.com 2019 - 2024. All rights reserved.