运行 多个 python 具有子进程的脚本 python
Running multiple python scripts with subprocess python
我正在尝试 运行 多个 python 脚本与 subprocess
在 linux OS
中并行
与此类似:Running multiple commands from multiple terminal windows from python script
这是我尝试过的:
subprocess.call(['gnome-terminal', '-e', "python3 ab.py"])
subprocess.call(['gnome-terminal', '-e', "python3 bc.py"])
subprocess.call(['gnome-terminal', '-e', "python3 cd.py"])
不幸的是,终端在瞬间闪烁并消失了。这有什么原因吗?添加 shell=True
使终端停留但不执行脚本。
subprocess.run
应该有效:
subprocess.Popen(['gnome-terminal', '-e', "python3", "ab.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "bc.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "cd.py"], shell=True)
编辑:
os.system("gnome-terminal -x python ab.py")
是否需要将命令行的所有部分拆分成单独的字符串?
subprocess.call(['gnome-terminal', '-e', "python3", "ab.py"])
我正在尝试 运行 多个 python 脚本与 subprocess
在 linux OS
与此类似:Running multiple commands from multiple terminal windows from python script
这是我尝试过的:
subprocess.call(['gnome-terminal', '-e', "python3 ab.py"])
subprocess.call(['gnome-terminal', '-e', "python3 bc.py"])
subprocess.call(['gnome-terminal', '-e', "python3 cd.py"])
不幸的是,终端在瞬间闪烁并消失了。这有什么原因吗?添加 shell=True
使终端停留但不执行脚本。
subprocess.run
应该有效:
subprocess.Popen(['gnome-terminal', '-e', "python3", "ab.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "bc.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "cd.py"], shell=True)
编辑:
os.system("gnome-terminal -x python ab.py")
是否需要将命令行的所有部分拆分成单独的字符串?
subprocess.call(['gnome-terminal', '-e', "python3", "ab.py"])