我正在使用子进程调用从 python 脚本调用可执行文件。这些是我使用的以下代码:
try:
p = subprocess.Popen([abc.exe], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
except Exception as e:
print str(e)
在 abc.exe 中,我在失败情况下返回 1,在成功情况下返回 0。但是我不知道如何在 python 脚本中检查返回值。
谢谢,
最佳答案
Popen.returncode
包含进程终止时的返回码。您可以确保使用 Popen.wait
.
关于python - 如何在python中获取返回状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18829118/