How to run another python program without holding up original?
This question already has an answer here:
使用subprocess
import subprocess
#code
prog = subprocess.Popen(['python', filename, args])
#more code
如果其他python程序是可导入的,并且需要的功能可以通过函数调用,那么最好使用多处理而不是subprocess
,因为参数可以作为Python对象传递,而不是通过字符串传递:
import somescript
import multiprocessing as mp
proc = mp.Process(target=somescript.main, args=...)
proc.start()
链接地址: http://www.djcxy.com/p/13492.html