python subprocess.Popen 控制台输出 实时监控百度网ping值

 

import subprocess

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

 

posted @ 2019-02-13 11:09  clemente  阅读(1713)  评论(0编辑  收藏  举报