可以使用的库是:applescript, 但是每执行一次tell.app()就会打开一个新终端,没办法连续性操作,网上的文档很少。
from applescript import tell #set what command you want to run here yourCommand = 'ls' tell.app( 'Terminal', 'do script"' + yourCommand + '"' , background = True) tell.app( 'Terminal', 'do script"' + "who" + '"')



