ITeye博客

python subprocess.Popen 监控控制台输出

mldxs · 2013-01-30 13:14 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。