#模块:Event #导入方法:from multiprocessing import Process,Event #模块方法: e=Event() e.is_set() #当is_set()的值为True时,e.wait()是非阻塞状态 #当is_set()的值为False时,e.wait()是阻塞状态 e.wait() #根据is_set的bool值决定阻塞或非阻塞状态 e.set() #将is_set()设为True e.clear() #将is_set()设为False #使用方法:交通信号灯原理 ##########交通信号灯模拟 from multiprocessing import Process,Event import time def Trafficlight(e): while 1: if e.is_set(): #当此条件为True时,表示绿灯,车辆可以通过 time.sleep(5) #表示绿灯的时间为5秒 print("