Controlling a python script from another script

后端 未结 4 1635
失恋的感觉
失恋的感觉 2020-12-11 12:55

I am trying to learn how to write a script control.py, that runs another script test.py in a loop for a certain number of times, in each run, reads

4条回答
  •  鱼传尺愫
    2020-12-11 13:53

    Yes you can use Python to control another program using stdin/stdout, but when using another process output often there is a problem of buffering, in other words the other process doesn't really output anything until it's done.

    There are even cases in which the output is buffered or not depending on if the program is started from a terminal or not.

    If you are the author of both programs then probably is better using another interprocess channel where the flushing is explicitly controlled by the code, like sockets.

提交回复
热议问题