这段python代码有问题,请大神帮我看下
importQueuefromthreadingimportThreaddefget(nums):whileTrue:ifmyqueue.empty()==False:p...
import Queue
from threading import Thread
def get(nums):
while True:
if myqueue.empty()==False:
print 'Thread %d : %s' %(nums, myqueue.get())
else:
break
def main():
thread=[]
nums=5
for a in xrange(5):
thread.append(Thread(target=get, args=(a+1)))
for a in thread:
a.setDaemon(True)
a.start()
if __name__ == "__main__":
global myqueue
myqueue=Queue.Queue()
list=[]
for a in xrange(100):
list.append(str(a+1))
for a in list:
myqueue.put(a)
main()
-------------------------------------------------------------------------
Traceback (most recent call last):
File "D:\software\python2.7.4\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "D:\software\python2.7.4\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
TypeError: get() argument after * must be a sequence, not int
该怎么改??求指教 展开
from threading import Thread
def get(nums):
while True:
if myqueue.empty()==False:
print 'Thread %d : %s' %(nums, myqueue.get())
else:
break
def main():
thread=[]
nums=5
for a in xrange(5):
thread.append(Thread(target=get, args=(a+1)))
for a in thread:
a.setDaemon(True)
a.start()
if __name__ == "__main__":
global myqueue
myqueue=Queue.Queue()
list=[]
for a in xrange(100):
list.append(str(a+1))
for a in list:
myqueue.put(a)
main()
-------------------------------------------------------------------------
Traceback (most recent call last):
File "D:\software\python2.7.4\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "D:\software\python2.7.4\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
TypeError: get() argument after * must be a sequence, not int
该怎么改??求指教 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询