python调用程序控制输出


import subprocess

// 注意要使用shell=True控制前面是命令,stdout指出采用管道方式转移stdout
pipe = subprocess.Popen("ls -l | grep ^d", shell=True, stdout=subprocess.PIPE)
// 此处即原本输出到stdout的内容
pipe.stdout.readlines()
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Haohao
  • Live
  • MisterWong
  • Slashdot
  • TwitThis
  • Upnews
  • Yahoo! Bookmarks

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>