我的问题很简单:我可以使用pexpect查看stderr上的某些输出吗?似乎pexpect.spawn()
只能用于期望stdout上的输出。在
乌托邦式的例子:
import pexpect
child = pexpect.spawn(...)
child.expect("hi", fd=pexpect.STDERR)
或者在散文中,“期待stderr上的字符串‘hi’”。在
我在文档中没有发现任何关于这种工具的提及,但是我确实注意到child
实例有一个stderr
属性。。。在
semi实现我想要的一种方法是在spawn参数中将stderr重定向到stdout,然后我们可以使用正则的expect()
。一定有更好的办法吗?在
干杯
对于后代来说,根据Thomas K的评论,这似乎是您想要的:
相关问题 更多 >
编程相关推荐