🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ import os import multiprocessing import time def new_process(number, age): print('子进程id = %d, 父进程id = %d' % (os.getpid(), os.getppid())) for i in range(3): print(number, age) time.sleep(1) if __name__ == '__main__': # 主进程id print(os.getpid()) # 创建子进程 pro = multiprocessing.Process(target=new_process, args=(100,), kwargs={'age':18}) pro.start() print(pro.pid) # 进程是否存货 print(pro.is_alive()) # 阻塞 pro.join() print("执行完毕") ~~~