赞
踩
import subprocess # 用于执行 shell命令 def _run(command): """执行shell脚本命令,并实时打印输出""" process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: output = process.stdout.readline().decode().strip() if output == '' and process.poll() is not None: break if output: print(output) def run(config): instructs = ["python main.py"] for key,val in config.items(): key = "--" + key instructs.append(key) instructs.append(str(val)) cmd = " ".join(instructs) _run(cmd)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。