【发布时间】:2022-01-04 13:48:11
【问题描述】:
到目前为止,我已经使用以下方法来捕获和处理子进程的输出:
process = subprocess.Popen(<some-command>, shell=True, stderr = subprocess.PIPE)
while True:
output = str(process.stderr.readline())
if process.poll() is not None:
break
if output:
if '<some-output>' in output:
print('<something>')
elif'<some-other-output>'in output:
print('something-else')
但是,我现在需要在程序执行其他操作时在后台监视输出。 这个程序是围绕 Glib Mainloop 构建的。
我尝试将它添加到 Glib Idle,但这似乎不起作用。
任何建议将不胜感激!
【问题讨论】:
标签: python subprocess stdout glib