更新时间:2022-06-22 04:24:10
直截了当的方法:
The straightforward approach:
execfile('main.py')
提供对输入和输出的细粒度控制,可以在后台运行进程:
Offers fine-grained control over input and output, can run processes in background:
import subprocess as sp
process=sp.Popen('other_file.py', shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
out, err = process.communicate() # The output and error streams.