我正在构建一个Python脚本来自动化我的构建过程,它使用subprocess.Popen调用GCC.我最初的尝试工作正常.
>>> import subprocess
>>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
>>> p.wait()
0
>>> p.communicate()
('', None)
Run Code Online (Sandbox Code Playgroud)
但是,一旦我将其他选项传递给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)
Run Code Online (Sandbox Code Playgroud)
可能导致此问题的任何想法?
不应该这样
p = Popen(['gcc', '-o', 'hello', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2253 次 |
| 最近记录: |