Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python Ï̳߳Ø


import Queue, threading, sys
from threading import Thread
import time,urllib
# working thread
class Worker(Thread):
   worker_count = 0
   def __init__( self, workQueue, resultQueue, timeout = 0, **kwds):
       Thread.__init__( self, **kwds )
       self.id = Worker.worker_count
       Worker.worker_count += 1
       self.setDaemon( True )
       self.workQueue = workQueue
       self.resultQueue = resultQueue
       self.timeout = timeout
       self.start( )
   def run( self ):
       ''' the get-some-work, do-some-work main loop of worker threads '''
       while True:
           try:
               callable, args, kwds = self.workQueue.get(timeout=self.timeout)
               res = callable(*args, **kwds)
               print "worker[%2d]: %s" % (self.id, str(res) )
               self.resultQueue.put( res )
           except Queue.Empty:
               break
           except :
               print 'worker[%2d]' % self.id, sys.exc_info()[:2]
               
class WorkerManager:
   def __init__( self, num_of_workers=10, timeout = 1):
       self.workQueue = Queue.Queue()
       self.resultQueue = Queue.Queue()
       self.workers = []
       self.timeout = timeout
       self._recruitThreads( num


Ïà¹ØÎĵµ£º

Python¶àÏß³Ì֪ʶµã


֪ʶµã
1.Ïß³ÌÊÇ“ÇáÁ¿¼¶”½ø³Ì£¬ÒòΪÏà½ÏÓÚ½ø³ÌµÄ´´½¨ºÍ¹ÜÀí£¬²Ù×÷ϵͳͨ³£»áÓýÏÉÙµÄ×ÊÔ´À´´´½¨ºÍ¹ÜÀíÏ̡߳£²Ù×÷ϵͳҪΪн¨µÄ½ø³Ì·ÖÅäµ¥¶ÀµÄÄÚÔÚ¿Õ¼äºÍÊý¾Ý£»Ïà·´£¬³ÌÐòÖеÄÏß³ÌÔÚÏàͬµÄÄÚ´æ¿Õ¼äÖÐÖ´ÐУ¬²¢¹²ÏíÐí¶àÏàͬµÄ×ÊÔ´¡£¶àÏ̳߳ÌÐòÔÚ½áÄÚ´æµÄʹÓÃЧÂÊÒªÓÅÓÚ¶à½ø³Ì³ÌÐò¡£
2.pythonÌṩÁËÍêÕûµÄ¶àÏß ......

PythonÓÐÓõÄÄ£¿é

http://chardet.feedparser.org/  ×Ô¶¯¼ì²â±àÂë
http://effbot.org/zone/celementtree.htm  cElementTree
http://github.com/jaybaird/python-bloomfilter bloomfilter
http://docs.python.org/library/threading.html#threading.activeCount threading ......

pythonÖеÄroundÄÚ½¨º¯Êý

 ½ñÌìÓÖɨÁËÒ»±éÊý×ÖÕâÒ»ÕÂ.. ¿´µ½ÁËround()º¯Êý, ÊÇÔÚpythonºËÐıà³Ì˼ÏëµÄ5.6.2½ÚµÄĩβ, Ô­ÎÄÈçÏÂ:
round(flt, ndig=0) ½ÓÊÜÒ»¸ö¸¡µãÊý flt ²¢¶ÔÆäËÄÉáÎåÈ룬±£´æ ndigλСÊý¡£
Èô²»Ìṩndig ²ÎÊý£¬ÔòĬÈÏСÊýµãºó0λ¡£
round()½öÓÃÓÚ¸¡µãÊý¡££¨ÒëÕß×¢£ºÕûÊýÒ²¿ÉÒÔ£¬ ²»¹ý²¢Ã»ÓÐʲô
ʵ¼ÊÒâÒ壩
Æäʵ, ×ö¸ö浄 ......

[¶À¼Ò]Google½«ÏÞÖÆPythonÓïÑÔµÄÓ¦Óà ¿ª·¢ÉçÇøÈÈÒé

2009-11-16 
Collin WinterÊÇPythonÉçÇøÒ»Î»ÆÄ¾ßÓ°ÏìÁ¦µÄ¿ª·¢Õߣ¬ËûÔøÊÇCPythonÏîÄ¿µÄºËÐÄ¿ª·¢ÕßÖ®Ò»¡¢Ò²ÔøÊÇUnladen Swallow£¨¼ûÎÄĩעÊÍ£©µÄºËÐÄ¿ª·¢Õߣ¬²ÎÓëÁ˺ܶàPythonÏîÄ¿µÄ¿ª·¢¡£½üÀ´´«ÎÅGoogle½«ÔÚÆäÐÂÏîÄ¿ÖÐÏÞÖÆPythonµÄʹÓã¬Îª´ËÓпª·¢Õߣ¨ÒÔK±íʾ£©ÔÚGoogle ÂÛ̳Öй«¿ªÑ¯ÎÊÁËCollin Winter£¬Collin Winte ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ