99-python-进程-Queue( 队列 )
# q = Queue() # 创建队列
# q.put(1) # 向队列中添加数据
# print(q.empty()) # 判断队列是否为空 False ( 不准确 -- 当返回结果的途中,可能结果为改变)
# print(q.full()) # 判断队列是否满了 False ( 不准确 )
# print(q.get()) # 取值
from multiprocessing import Queue,Process
def produce(q):
q.put('hello')
def consume(q):
print(q.get())
if __name__ == '__main__':
q = Queue()
p = Process(target=produce,args=(q,))
p.start()
c = Process(target=consume,args=(q,))
c.start()

浙公网安备 33010602011771号