如果我有一个这样的程序:
for i in range (25000):
do something
if i == 5000:
run new_script.py in a new thread/process
continue as before
我该怎么做?
最佳答案
将new_script.py的内容放入函数中并导入
from threading import Thread
from new_script import f
for i in range (25000):
do_something()
if i == 5000:
Thread(target=f, args=(arg1, arg2)).start()
关于python - 如何在正在运行的 python 脚本中启动其他脚本(新线程或进程?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56749134/