在不等待脚本执行的情况下调用脚本 [英] Python calling script without waiting for it to execute
本文介绍了在不等待脚本执行的情况下调用脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
main.py
os.system('"F:second.py"')
//continue the rest of the code without waiting for second.py to finish
Second d.py
//do stuff
推荐答案
您可以尝试subprocess
first.py
import subprocess
subprocess.Popen(["python.exe", "second.py"])
print "done"
Second d.py
import time
for i in range(10):
print i
time.sleep(10)
编辑:
如果要完全分隔第一个和第二个脚本,请添加一个标志
first.py
import subprocess
subprocess.Popen(["python.exe", "second.py"], creationflags=subprocess.CREATE_NEW_CONSOLE)
print "done"
这篇关于在不等待脚本执行的情况下调用脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文