02 查看线程的进程id
import os from threading import Thread # from multiprocessing import Process def f1(n): print('1号',os.getpid()) print('%s号线程任务'%n) def f2(n): print('2号',os.getpid()) print('%s号线程任务'%n) if __name__ == '__main__': t1 = Thread(target=f1,args=(1,)) t2 = Thread(target=f2,args=(2,)) t1.start() t2.start() print('主线程',os.getpid()) print('主线程')