Python:同时启动多个脚本 [英] Python: start many scripts at the same time
本文介绍了Python:同时启动多个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个程序启动第一个程序.但我也想运行第二个并行.如何使用脚本启动两个或多个程序?
This program starts the first program. But I also want to run the second parallel. How can i start two or more programs with a script?
# start many programs
execfile('C:/Dokumente und Einstellungen/schnei17/Desktop/python/zeit/1.py')
print 1
execfile('C:/Dokumente und Einstellungen/schnei17/Desktop/python/zeit/2.py')
print 2
推荐答案
尝试使用 subprocess python 模块:
try with the subprocess python module :
import subprocess
subprocess.Popen(["python.exe", 'C:/Dokumente und Einstellungen/schnei17/Desktop/python/zeit/1.py'])
subprocess.Popen(["python.exe", 'C:/Dokumente und Einstellungen/schnei17/Desktop/python/zeit/2.py'])
它将并行启动 2 个脚本(如果您的 python.exe 在 PATH 中).
It will launch the 2 scripts in parallel (if your python.exe is in PATH).
这篇关于Python:同时启动多个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文