赞
踩
想要使用python脚本调用多个可执行文件exe,最后再将调用的py文件打成exe
代码如下:
# -*- coding: utf-8 -*-# # ----------------------------------------- # Name: start_task # Description: # Author: sihai # Date: 2021/3/9 # ----------------------------------------- import multiprocessing import os def task_one(exe_name): main = os.path.join(os.path.dirname(__file__), exe_name) try: f = os.popen(main) print(f.read()) except Exception as e: print(e) if __name__ == '__main__': multiprocessing.freeze_support() exe_list = ['aaaa.exe', 'bbbb.exe', 'cccc.exe', 'dddd.exe'] process = [] for exe in exe_list: task = multiprocessing.Process(target=task_one, args=(exe,)) # 创建子进程 task.start() # 启动子进程 process.append(task) for i in process: i.join()
在将本py文件打包成exe时,切记加上multiprocessing.freeze_support(),否则会起多个进程,导致电脑卡死!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。