from subprocess import Popen
from time import sleep
for index in range(1,10):
# start the child
process = Popen('./test')
# sleep to allow the child to draw its buttons
sleep(.333)
# send the keystroke
os.system('xdotool key Return')
# wait till the child exits
process.wait()
os.system
在子进程退出之前不会返回。 你需要subprocess.Popen
。 在发送击键之前sleep
一段时间也是个好主意 (子进程准备接受用户输入可能需要一些时间):我不是舒尔,你需要最后一行。如果所有9子进程都应该保持活动状态,则将其移除。你知道吗
相关问题 更多 >
编程相关推荐