Python子进程:使用Pipe和通信的困难

问题描述 投票:-1回答:1

C Code of binary format3

Python Code

我基本上试图运行'(./ format3 | attackString)| grep searchString'在我的python脚本中,但我无法访问format3进程的管道(代码中的宝贝),因为它在通信调用后关闭了。

我需要通信呼叫才能将我的attackString提供给二进制文件。我知道我可以将婴儿的stdout写入文件,然后将该文件用作grep的stdin,但我觉得必须有另一种方法来解决这个问题。

python subprocess
1个回答
-1
投票

考虑使用sh库,因为它解决了功能组合的管道问题:https://amoffat.github.io/sh/#piping

它是一个非常整洁的库,似乎只能解决你的问题。

© www.soinside.com 2019 - 2024. All rights reserved.