下面小编就为大家带来一篇python 捕获shell脚本的输出结果实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
import subprocess
output =Popen([“mycmd”,”myarg”], stdout=PIPE).communicate()[0]
import subprocess
p = subprocess.Popen([‘ls’,’-a’], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err来源gaodai$ma#com搞$代*码*网 = p.communicate()
print out
# work on Unix/Linux only
import commands
print commands.getstatusoutput(‘wc -l file’)[1]
以上就是python 捕获shell脚本的输出结果实例的详细内容,更多请关注gaodaima搞代码网其它相关文章!