我如何从另一个 python 脚本 运行 一个 python 脚本,而第二个脚本不会中断第一个脚本?
How do i run a python script from another python script without the secondary script interrupting the first?
所以我有主要的 python 脚本,我想从我的主文件中调用另一个 python 脚本,但是,每当我这样做时,我调用的脚本都会取代原来的脚本。有什么方法可以在后台调用 python 脚本以使其不中断控制台中的主脚本?
您好,我使用线程和子进程为您制作此脚本 运行 在后台其他 python 脚本(没有第二个脚本中断第一个)
import threading
from subprocess import call
def thread_second():
call(["python", "secondscript.py"])
processThread = threading.Thread(target=thread_second) # <- note extra ','
processThread.start()
print 'the file is run in the background'
所以我有主要的 python 脚本,我想从我的主文件中调用另一个 python 脚本,但是,每当我这样做时,我调用的脚本都会取代原来的脚本。有什么方法可以在后台调用 python 脚本以使其不中断控制台中的主脚本?
您好,我使用线程和子进程为您制作此脚本 运行 在后台其他 python 脚本(没有第二个脚本中断第一个)
import threading
from subprocess import call
def thread_second():
call(["python", "secondscript.py"])
processThread = threading.Thread(target=thread_second) # <- note extra ','
processThread.start()
print 'the file is run in the background'