我在寫一個調用命令行(例如python本身)的Python代碼,該命令將打開它自己的shell。 Python如何控制這個shell?Python - 打開一個打開另一個shell的命令
import subprocess
subprocess.call(['./testprg'])
# testprg will open its own shell
# so the code below will not work
subprocess.call(['i 2'])
testprg是打開shell提示符的另一個程序。輸入「I 2」將觸發與值2
或['winpexpect'(https://bitbucket.org/geertj/winpexpect/wiki/Home)在Windows – jfs