1. 程式人生 > >python subprocess.Popen 控制臺輸出 實時監控百度網ping值

python subprocess.Popen 控制臺輸出 實時監控百度網ping值

pan com break 控制臺輸出 process 百度 div while 實時

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

python subprocess.Popen 控制臺輸出 實時監控百度網ping值