Using Python to run executable and fill in user input

后端 未结 4 1242
太阳男子
太阳男子 2020-12-15 12:25

I\'m trying to use Python to automate a process that involves calling a Fortran executable and submitting some user inputs. I\'ve spent a few hours reading through similar

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 13:01

    By the time, you reach ps.communicate('argument 2'), ps process is already closed as ps.communicate('argument 1') waits until EOF. I think, if you want to write multiple times at stdin, you might have to use:

    ps.stdin.write('argument 1')
    ps.stdin.write('argument 2')
    

提交回复
热议问题