![]() |
#2
外部三电铃2010-04-06 20:06
|
附上代码:
-------------
jobs=Queue.Queue()
limit=20
def thread():
while True:
i=jobs.get()
line=linecache.getline('nick.txt',i)
lj=('(.*?)\n')
mat=lj.match(line)
if mat:
nick=mat.groups()[0]
try:
f=urllib.urlopen('http://'+nick+'.').read()
print str(i)+'\t'+nick+'\t'+f[:10]
except:
pass
jobs.task_done()
for n in xrange(limit):
t = threading.Thread(target=thread)
t.setDaemon(True)
t.start()
for i in xrange(10000):
jobs.put(i)
jobs.join()
----------
thread()部分还要做些其他的处理,这个程序问题在哪里啊?
跪求大虾指点!!