Python3:多进程-小例子
参考链接:
https://www.cnblogs.com/284628487a/p/5590857.html
----
代码:
#!/usr/bin/python3 import os print("getpid : %d" % os.getpid()) pid = os.fork() if pid == 0 : print("child ! getpid :%d \t getppid() :%d " % (os.getpid(), os.getppid())); else: print("parent ! getpid :%d \t getppid() :%d " % (os.getpid(), os.getppid()));
运行结果:
getpid : 20198 parent ! getpid :20198 getppid() :16844 child ! getpid :20199 getppid() :20198