进程
import os
print("当前进程:", os.getpid(), " 父进程:", os.getppid())
线程
import threading
t = threading.currentThread()
print('Thread id : %d' % t.ident)
案例
import os
import threading
def add_func(x, y):
print("当前进程:", os.getpid(), " 父进程:", os.getppid())
t = threading.currentThread()
print('Thread id : %d' % t.ident)
return x + y
print(add_func(3, 4))