---
title: "python subprocess.Popen   监控控制台输出"
author: "mldxs"
date: "2013-01-30T13:14:00Z"
tags: []
slug: "python-subprocess-popen"
draft: false
lastmod: "2013-01-31T15:56:57Z"
id: 1781710
url: "https://mldxs.iteye.com/blog/1781710"
---

file\_out = subprocess.Popen('ping www.baidu.com', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)  
while True:  
line = file\_out.stdout.readline()  
print(line)  
if subprocess.Popen.poll(file\_out)==0: #判断子进程是否结束  
break