浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

How to get stdout and stderr using Python's subprocess module « SaltyCrane Blog

from subprocess import Popen, PIPE, STDOUT cmd = 'ls /etc/fstab /etc/non-existent-file' p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read() print output
posted on 2012-05-12 23:21  lexus  阅读(231)  评论(0编辑  收藏  举报