小乔 发表于 2017-5-7 12:29:26

python 调用系统命令并获得标准输出,错误输出

  转自: http://reader.youdao.com/sharelite?itemId=-447170961514257704&method=viewSharedItemThroughLink&sharedBy=-1137845767117085734 
  
import subprocess
cmd_res = {}
res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True);
cmd_res['out']=res.stdout.readlines();
cmd_res['err']=res.stderr.readlines();
页: [1]
查看完整版本: python 调用系统命令并获得标准输出,错误输出