You probably want subprocess.Popen
. To communicate with the process, you'd use the communicate
method.
e.g.
process=subprocess.Popen(['command','--option','foo'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
inputdata="This is the string I will send to the process"
stdoutdata,stderrdata=process.communicate(input=inputdata)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…