>> import subprocess >>> p = -6ren">
gpt4 book ai didi

Python subprocess.Popen - 添加 GCcflags导致 "no input files"错误

转载 作者:行者123 更新时间:2023-11-28 21:30:48 26 4
gpt4 key购买 nike

我正在构建一个 Python 脚本来自动化我的构建过程,该脚本使用 subprocess.Popen 调用 GCC。我最初的尝试效果很好。

>>> 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)

关于Python subprocess.Popen - 添加 GCcflags导致 "no input files"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1448558/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com