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£¬²»Ö ......
#coding=utf-8
from math import sqrt,cos,sin
import Image, ImageDraw
class SpireShape(object):
def __init__(self, draw):
self.draw = draw
self.line_width = 1
& ......
ÕâÁ½ÌìÔÚѧϰpythonÓïÑÔ£¬Ò²Ñ§×ÅдÁ˸öͨѶ²¾£¬Á·Ï°ÈëÃÅÏ£¡
¹¦ÄÜ°üÀ¨ÒÔÏ£º
1¡¢Ôö¼ÓÒ»Ìõ¼Ç¼
2¡¢É¾³ýÒ»Ìõ¼Ç¼
3¡¢ÐÞ¸ÄÒ»Ìõ¼Ç¼
4¡¢²éѯһÌõ¼Ç¼
5¡¢ÏÔʾÕû¸öͨѶ²¾
6¡¢°ïÖúÌáʾ
7¡¢°æ±¾ÏÔʾ
8¡¢Í˳öµÈ
Ê×ÏȽ¨Á¢Ò»¸öPersonÀ࣬¼´Person.pyÎļþ£¬ÓÃÀ´±£´æÁªÏµÈ˼Ǽ£º
class Person:
def __init__(self, nam ......
»°ËµPython£¨¶þ£©
×Ô´ÓС°×ÉÏÍêµÚÒ»¿Î£¬Python¼òÖ±³ÉÁËËûµÄ¿Æѧ¼ÆËãÆ÷¡£Ã¿ÌìÔçÉÏ£¬Ð¡°××ÜÊDz»Íü“Á·Ï°”Ò»ÏÂPython¡£
>>> 10000*1.2**40
14697715.679690843
“ºÙºÙ£¬ÎÒ·¢´ïÁË£¡”С°×ÔÚɵЦ×Å£¬ºÃÏñÔÚ×öÃΣ¬“ËÄÊ®Äêºó¾ÍÊÇÒÚÍò¸»ÎÌÀ²!”
С²ËÇÃÁËÇÃС°×µ ......
#filename Seek.py
import unicodedata
import sys
import os
class Seek():
"""
¹¦ÄÜ:²éÕÒÖÐÎÄ,²¢Ìæ»»³ÉÖ¸¶¨×Ö·û»ò×Ö·û´®
ʹÓ÷½·¨:python½Å±¾Ó÷¨
²ÎÊý˵Ã÷:
-d& ......