关于Python中的subprocess.call很奇怪

时间:2017-08-11 13:48:26

标签: python

因为subprocess.call调用cmd .exe flash off,只返回值'1',表示运行错误。我只是截图解释。

在win cmd下,它运行良好。为什么它在subprocess.call中断?

Year:    979
Year:    980
Year:    981
Year:    982
Year:    983
Year:    984
Year:    985
Year:    986
Year:    987
Year:    988
Year:    989
SPINUP: residual trend  = -0.000069
SPINUP: number of years = 990
H:\calibration\bgcclimb>pointbgc.exe .\ini\spinup\t59_13_79_29_11_80_8.ini

在Python中使用subproceess.call:返回值'1',而不是'0'

 subprocess.call([r'H:\calibration\bgcclimb\pointbgc.exe',r'.\ini\spinup\t59_13_79_29_11_80_8.ini'])
Out[7]: 1

使用subprocess.Popen检查stderr:

process = subprocess.Popen([r'H:\calibration\bgcclimb\pointbgc.exe',r'.\ini\spinup\t59_13_79_29_11_80_8.ini'], shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out, err = process.communicate()
errcode = process.returncode

err
 Out[3]: b"Can't open .\\ini\\spinup\\t59_13_79_29_11_80_8.ini for ascii read ... Exiting\r\nError opening init file, pointbgc.c\r\n"

0 个答案:

没有答案