Discuss / Python / 求解？？？？

### 求解？？？？

Topic source

#### 楠先森咩

#1 Created at ... [Delete] [Delete and Lock User]

 while True:
value = q.get(True)
print('Get %s from queue.' % value)


print(q.get())


Process to write: 25892
Put A to queue...
Get A from queue.
Put B to queue...
B
Put C to queue...
Get C from queue.


#### 楠先森咩

#2 Created at ... [Delete] [Delete and Lock User]

def read(q):
print('Process to read: %s' % os.getpid())
for i in range(q.qsize()):
value=q.get()
print('Get %s from queue...' % value)


#### 我是坏人0118

#3 Created at ... [Delete] [Delete and Lock User]

write 的延时应该就是让写入完成 然后才能取的到

Process to write: 9108
Put A to queue...
Put B to queue...
Put C to queue...
Get A from queue.
Get B from queue.
Get C from queue.


Process to write: 4344
Put A to queue...
Put B to queue...
Put C to queue...
Get A from queue.
Put d to queue...
Get B from queue.Put e to queue...
Get C from queue.
Get d from queue.
Get e from queue.


while True:
value = q.get(True)
print('Get %s from queue. \n%s' % (value,value))


Process to write: 2988
Put A to queue...
Get A from queue.
A
Put B to queue...
Get B from queue.
B
Put C to queue...
Get C from queue.
C
Put d to queue...
Get d from queue.
d
Put e to queue...
Get e from queue.
e


#### 新雨沐晨风

#4 Created at ... [Delete] [Delete and Lock User]

queue是队列，get()之后就没了，所以你第一次循环get了两次，打印了第二次的 b，第二次循环打印的时候是第四次get，已经没值了

• 1