Python Ï̳߳صÄʵÏÖ
import urllib2
import time
import socket
from datetime import datetime
from thread_pool import *
def main():
url_list = {"sina":"http://www.sina.com.cn",
"sohu":"http://www.sohu.com",
"yahoo":"http://www.yahoo.com",
"xiaonei":"http://www.xiaonei.com",
"qihoo":"http://www.qihoo.com",
"laohan":"http://www.laohan.org",
"eyou":"http://www.eyou.com",
"chinaren":"http://www.chinaren.com",
"douban":"http://www.douban.com",
"163":"http://www.163.com",
"daqi":"http://www.daqi.com",
"qq":"http://www.qq.com",
"baidu_1":"http://www.baidu.com/s?wd=asdfasdf",
"baidu_2":"http://www.baidu.com/s?wd=dddddddf",
"google_1":"http://www.baidu.com/s?wd=sadfas",
"google_2":"http://www.baidu.com/s?wd=sadflasd",
"hainei":"http://www.hainei.com",
"microsoft":"http://www.microsoft.com",
"wlzuojia":"http://www.wlzuojia.com"}
#ʹÓÃÏ̳߳Ø
socket.setdefaulttimeout(10)
print 'start testing'
wm = WorkerManager(50)
for url_name in url_list.keys():
wm.add_job(do_get_con, url_name, url_list[url_name])
wm.wait_for_complete()
print 'end testing'
def do_get_con(url_name,url_link):
try:
fd = urllib2.urlopen(url_link)
data = fd.read()
f_hand = open("/tmp/ttt/%s" % url_name,"w")
f_hand.write(data)
f_hand.close()
except Exception,e:
pass
if __name__ == "__main__":
main()
thread_poolµÄ´úÂ루·ÇÔ´´£¬×ª×Ô£ºhttp://blog.daviesliu.net/2006/10/09/234822/£©
import Queue, threading, sys
from threading import Thread
import time
import urllib
# working thread
class Worker(Thread):
worker_count = 0
timeout = 1
def __init__( self, workQueue, resultQueue, **kwds):
Thread._
Ïà¹ØÎĵµ£º
ÎÊÌâÃèÊö
ÔÚC++ºÍPython»ìºÏ±à³ÌÖУ¬ÔÚÈí¼þ·¢²¼µÄʱºòÐèÒª½«pythonµÄ½âÊÍÆ÷´ò°üµ½°²×°³ÌÐòÖУ¬ÎªÁËÌá¸ßÓû§ÌåÑ飬ÎÒÃÇÐèÒªÈÃÓû§¸Ð¾õ²»µ½pythonµÄ°²×°£¬Èç¹ûÓû§ÒѾ°²×°ÓÐpythonµÄ»·¾³£¬ÎÒÃÇÒ²Òª±£Ö¤²»Ó°ÏìÏÖÓеÄϵͳ¡£
½â¾ö·½°¸
ÔÚPython2.5ÒÔºó£¬pythonÖ§³Ö´ÓzipÎļþÖжÁÈ¡python½Å±¾Îļþ£¬Ö§³Ö¶ÁÈ¡py£¬pyc£¬pyo£¬²»Ö ......
Memcached
ÊÇdanga.com£¨ÔËÓªLiveJournalµÄ¼¼ÊõÍŶӣ©¿ª·¢µÄÒ»Ì×·Ö²¼Ê½ÄÚ´æ¶ÔÏ󻺴æÏµÍ³£¬ÓÃÓÚÔÚ¶¯Ì¬ÏµÍ³ÖмõÉÙÊý¾Ý¿â¸ºÔØ£¬ÌáÉýÐÔÄÜ¡£
ÍøÉÏÓкིܶµ½Memcached For LinuxµÄ°²×°½Ì³Ì£¬µ«ÊÇMemcached For Win32 and PythonµÄ¾ÍÉõÉÙ£¬Å¼¶ûgoogleÕÒµ½Ò»Æª
±È½ÏÏà½üµÄÓ¢ÎĽ̳̣¬¾õµÃ ......
ÉèÖÃEmacsµÄHOME,¿ÉÒÔÔÚscratch bufferÖÐÊäÈ룺(insert (getenv "HOME"))²é¿´
ÏÂÔØpython-mode.el
ÓÃEmacs´ò¿ªpython-mode.elÈ»ºóM-x byte-compile-file±àÒëpython-mode.elΪelc
C-h v²é¿´load-path±äÁ¿
ÔÚHOME/.emacs.d/init.elÖÐÌí¼Ó(setq load-path (cons "D:\\emacs-23.1-bin-i386" load-path))
½«pyÎļþÓëpytho ......
#filename Seek.py
import unicodedata
import sys
import os
class Seek():
"""
¹¦ÄÜ:²éÕÒÖÐÎÄ,²¢Ìæ»»³ÉÖ¸¶¨×Ö·û»ò×Ö·û´®
ʹÓ÷½·¨:python½Å±¾Ó÷¨
²ÎÊý˵Ã÷:
-d& ......