Python的subprocess.Popen - 加入GCC标志结果“没有输入文件”的错误
-
11-09-2019 - |
题
我要建一个Python脚本来自动编译过程中,GCC使用subprocess.Popen其调用。我最初的尝试工作正常。
>>> import subprocess
>>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
>>> p.wait()
0
>>> p.communicate()
('', None)
然而,一旦予传递额外的选项,以GCC我得到的错误“没有输入文件”,如下所示:
>>> import subprocess
>>> p = Popen(['gcc', '-o hello hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
>>> p.wait()
1
>>> p.communicate()
('gcc: no input files\r\n', None)
任何想法可能会造成这个问题?
解决方案
不应该认为是
p = Popen(['gcc', '-o', 'hello', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
不隶属于 StackOverflow