打印出返回值,我用Python调用的bash执行另一个bash脚本:如何避免使用os.system()在python
begin = int(sys.argv[1])
result = os.system("/tesladata/isetools/cdISE.bash %s" %begin)
我打印result
后,它不仅给我的输出还有退货状态(这里的0
)。 如果我只需要输出,我该怎么办?
而且,为了好奇,有多少种方法可以在Python中调用bash?如果有人能够提供一些如何使用它们的参考资料,我会很高兴,到目前为止我只找到os.system()
和os.popen()
。
你的第二个问题是在这里(http://stackoverflow.com/questions/3479728/is-it-good-style-to-call-bash-commands-within-a-python-script-using-os-讨论systemb)和(http://stackoverflow.com/questions/4256107/running-bash-commands-in-python)Here – Bry6n 2012-01-11 16:49:38