1
這是我的代碼:與FIFO隊列我python3線程PROG沒有工作
import threading
import queue
qq=queue.Queue(10)
def x11grab(n):
print('haha')
while True:
a='abcd'+str(n)
n+=1
qq.put(a)
print('put queue:',a)
def rtpsend():
while True:
s=qq.get()
head=s[:4]
body=s[4:]
print('head',head)
print('body',body)
t1=threading.Thread(target=x11grab,args=(1,))
t2=threading.Thread(target=rtpsend)
t1.start
t2.start
我想x11grab()函數把字符串 'ABCD1', 'ABCD2' ......到隊列中,rtpsend()函數從隊列中獲取字符串並顯示它。這是一個演示,但它不起作用。我認爲你的建議可能會有幫助。:-)
OMG!我很...謝謝你,我應該從現在開始仔細編碼。 – socket 2013-05-05 10:24:06