python

Posted 盾钝

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python相关的知识,希望对你有一定的参考价值。

import os

print(‘Process (%s) start...‘ % os.getpid())
# Only works on Unix/Linux/Mac:
pid = os.fork()
#os.fork()创建2个进程,返回值为0时,表示子进程,返回值为子进程号是---父进程os.getpid()表示当前进程 if pid == 0: print(‘I am child process (%s) and my parent is %s.‘ % (os.getpid(), os.getppid())) else: print(‘I (%s) just created a child process (%s).‘ % (os.getpid(), pid))

  

以上是关于python的主要内容,如果未能解决你的问题,请参考以下文章