当前位置:主页 > 软件编程 > Python代码 >

python实时获取外部程序输出结果的方法

时间:2021-05-02 08:18:43 | 栏目:Python代码 | 点击:

如下所示:

s=subprocess.Popen("ping baidu.com -t",bufsize=0,stdout=subprocess.PIPE,universal_newlines=True)
while True:
  nextline=s.stdout.readline()
  print(nextline.strip())
  if nextline=="" and scan.poll()!=None:
    break

您可能感兴趣的文章:

相关文章