简体   繁体   English

有一种输出标准输出的方法吗?

[英]Is there a way to print stdout as it is outputted?

If if I ran 如果我跑了

from plumbum import local
local['ping']['google.com']()

It would just hang indefinitely because ping executes forever. 它会无限期地挂起,因为ping会永远执行。

Is there a way to print the output of ping as it executes, perhaps in a generator or something, like 有没有办法在执行时打印ping的输出,也许在生成器之类的东西中,例如

for a in local['ping']['google.com']():
    print a

According to the documentation , this should work: 根据文档 ,这应该起作用:

from plumbum import local, FG

local["ping"]["google.com"] & FG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM