我正在嘗試從 python 腳本檔案在新視窗中啟動子行程 - 超時 15 秒,然后終止該行程而不關閉主終端視窗。
這是我到目前為止...
cmd=subprocess.Popen('file_name.sh')
subprocess.Popen('gnome terminal -c cmd')
time.sleep(15)
Popen.terminate(cmd)
uj5u.com熱心網友回復:
試試這個 :
import subprocess
import time
proc = subprocess.Popen(('gnome-terminal', '--', 'file_name.sh'))
time.sleep(15)
subprocess.Popen(('pkill', '-f', 'file_name.sh'))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/420216.html
標籤:
