标签:color display one rgb cname 进程 code port return
import os from multiprocessing import Process def f(x): print(‘子进程id :‘,os.getpid(),‘父进程id :‘,os.getppid()) return x*x if __name__ == ‘__main__‘: print(‘主进程id :‘, os.getpid()) p_lst = [] for i in range(5): p = Process(target=f, args=(i,)) p.start()
macname@MacdeMacBook-Pro py % python3 cccccc.py 主进程id : 57001 子进程id : 57002 父进程id : 57001 子进程id : 57003 父进程id : 57001 子进程id : 57004 父进程id : 57001 子进程id : 57005 父进程id : 57001 子进程id : 57006 父进程id : 57001 macname@MacdeMacBook-Pro py %
import time from multiprocessing import Process def f(name): print(‘hello‘, name) time.sleep(1) if __name__ == ‘__main__‘: p_lst = [] for i in range(5): p = Process(target=f, args=(‘bob‘,)) p.start() p_lst.append(p)
macname@MacdeMacBook-Pro py % python3 cccccc.py
hello bob
hello bob
hello bob
hello bob
hello bob
macname@MacdeMacBook-Pro py %
标签:color display one rgb cname 进程 code port return
原文地址:https://www.cnblogs.com/sea-stream/p/14193099.html