Asynchronously redirect stdout/stdin from embedded python to c++?

后端 未结 3 2000
忘了有多久
忘了有多久 2021-02-07 10:04

I am essentially trying to write a console interface with input and output for an embedded python script. Following the instructions here, I was able to capture stdout:

3条回答
  •  太阳男子
    2021-02-07 10:26

    To process all available input inside Python I'd recommend the fileinput module.

    If you want to handle input as line-by-line commands, (such as in an interactive interpreter), you might find the python function raw_input useful.

    To redirect stdin using a similar helper class such as the ones you've used above, the function to override is readline, not read. See this link for more info on that (and also raw_input).

    Hope this helps, Supertwang

提交回复
热议问题