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

ÓÃpythonдµÄץȡÌìÆøÔ¤±¨µÄ½Å±¾

ÓÃpythonдµÄץȡÌìÆøÔ¤±¨µÄ½Å±¾
http://blog.chinaunix.net/u2/82009/showart_2166843.html
´Ó×òÌ쿪ʼµÄ¿´¹ØÓÚÍøÂçץȡµÄ¶«Î÷£¬¶øÇÒ×Ô¼ºµÄÓõÄÊÇawesome £¬ËùÒÔдÁËÕâ¸öÌìÆøÔ¤±¨µÄ½Å±¾¸øÎÒµÄawesome£¬Õâ¸öÌìÆø½Å±¾Ö±½ÓÈ¡ÏÂÀ´µÄ»°ÊÇÆßÌìµÄÌìÆøÔ¤±¨´ÓÖйúÌìÆøÍøÉÏ£¬ÎÒºóÃæ¶ÔËü×öÁË´¦Àí£¬Óõ½ÁËÎÒµÄawesomeÉÏ
Ч¹û£º1ÈÕÐÇÆÚÒ»Ò¹¼ä Òõ µÍΠ4¡æ ÎÞ³ÖÐø·çÏò ΢·ç | 2ÈÕÐÇÆÚ¶þ СÓê --> Óê¼ÐÑ© 3¡æ --> 6¡æ | 3ÈÕÐÇÆÚÈý Óê¼ÐÑ© 1¡æ --> 5¡æ
ÎÒֻȡÁËÈýÌìµÄÔ¤±¨£¬ÈýÌìÒѾ­¹»ÁË£¬ÏÂÃæ³ÌÐòµÄ×¢ÊÍ Ó¢ÎÄʵÔÚÓеã¹ý²»Á˹Ø
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
#!/usr/bin/env python
# weather html parser
from HTMLParser import HTMLParser
import sys,urllib2,string,re
# define a class to parser a html
class HtmlParser(HTMLParser):
    def __init__(self):
        self.data=''
        self.readingdata=0
        HTMLParser.__init__(self)
    def handle_starttag(self,tag,attrs):
        if tag == 'td':
            self.readingdata=1
    def handle_data(self,chars):
        if self.readingdata:
            self.data+=chars
    def handle_endtag(self,tag):
        if tag=='td':
            self.readingdata=0
    def cleanse(self):
        self.data = re.sub('\s+',' ', self.data)
    def getdata(self):
        self.cleanse()
        return self.data
# this url is a place where you want to know the weather forecast
url="http://www.weather.com.cn/html/weather/101210501.shtml


Ïà¹ØÎĵµ£º

ÒÔPython Imaging Library ½øÐÐÓ°Ïñ×ÊÁÏ´¦ÀíPIL


1   Ó°ÏñÓëͼÐÎ×ÊÁϵĴ¦Àí
ÌÖÂÛͼÐÎ(Ó°Ïñ) ±¾ÉíµÄ´¦Àí£¬¶øÌÖÂÛµÄÄÚÈݽ«»á¼¯ÖÐÔÚPython Imaging Library (PIL) ÕâÒ»Ì׳Ìʽ¿âÉÏ¡£
PIL ÊÇPython ÏÂ×îÓÐÃûµÄÓ°Ïñ´¦ÀíÌ×¼þ£¬ÓÉÐí¶à²»Í¬µÄÄ£×éËù×é³É£¬²¢ÇÒÌṩÁËÐí¶àµÄ´¦Àí¹¦ÄÜ£¬ÔÊÐíÎÒÃÇÔÚ¼òµ¥µÄPython ³ÌʽÀï½øÐÐÓ°ÏñµÄ´¦Àí¡£ Ê¹ÓÃÏñPIL ÐíÑùµÄ³Ìʽ¿âÌ ......

PythonºÍSingleton £¨µ¥¼þ£©Ä£Ê½

ÎÒÖªµÀµÄÒ»ÖÖÔÚ
python
ÖÐ
Singleton mode
µÄʵÏÖÈçÏ£º
class Foo: pass
def
instance():
   
global inst
   
try:
       
inst
   
except:
       
inst =
Foo
()
&n ......

ÓÃPythonʵÏÖ¼òµ¥µÄÒÅ´«Ëã·¨

ÓÃPythonʵÏÖ¼òµ¥µÄÒÅ´«Ëã·¨
2010-02-15 14:00
Õ⼸ÌìÒ»Ö±ÔÚÓÃPythonдһ¸ö¼òµ¥µÄÒÅ´«Ëã·¨£¬ºÃ×Ô¼ºÄÃÀ´ÊµÑé¡£¶Ï¶ÏÐøÐøµÄÕÛÌÚÁ˼¸Ì죬½ñÌìÏÂÎçÖÕÓÚдÁËÒ»¸ö¼òµ¥µÄ³öÀ´¡£Õû¸ö´úÂ뻹ÊÇ·ÂÕÕ¡¶ÓÎÏ·±à³ÌÖеÄÈ˹¤ÖÇÄܼ¼Êõ¡·ÖеĴúÂëÀ´Ð´µÄ¡£Èç¹ûÏë¼òµ¥µÄѧϰһÏÂÒÅ´«Ëã·¨ÒÔ¼°¼òµ¥Ó¦Óá¶ÓÎÏ·±à³ÌÖеÄÈ˹¤ÖÇÄܼ¼Êõ¡·ÊDz»´íµÄÑ¡Ôñ¡£ ......

[python]PLYÄ£¿é Lex/YACCµÄpythonʵÏÖ

  PLYÄ£¿é ÊÇLex/YACCPython µÄʵÏÖ£¬¿ÉÒÔÓÃÀ´ÊµÏÖ´Ê·¨·ÖÎö/Óï·¨·ÖÎö£¬µ«ÈçºÎÓ㬻¹Ã»Ñо¿£¬ÒÔºóÓÐʱ¼äÔÙÑо¿°É£»
  Ö÷Ò³: http://www.dabeaz.com/ply/
  pycparserÄ£¿é ÊÇʹÓÃPLYÄ£¿é·ÖÎöcÓïÑÔÓï·¨µÄÄ£¿é£¬Ã»Ê²Ã´Îĵµ£¬µ«Ä£¿é×Ô´øÁËÀý×ӺͲâÊÔÓÃÀý¡£
   Ö÷Ò³: http://code.google.com/p/pycpa ......

python ¼¯ºÏÔËËã

¼¯ºÏÀàÐͲÙ×÷·û£¨ËùÓеļ¯ºÏÀàÐÍ£©
ÁªºÏ( | )
ÁªºÏ(union)²Ù×÷ºÍ¼¯ºÏµÄOR(ÓֳƿɼæÎöÈ¡(inclusive
disjunction))ÆäʵÊǵȼ۵ģ¬Á½¸ö¼¯
ºÏµÄÁªºÏÊÇÒ»¸öм¯ºÏ£¬¸Ã¼¯ºÏÖеÄÿ¸öÔªËض¼ÖÁÉÙÊÇÆäÖÐÒ»¸ö¼¯ºÏµÄ³ÉÔ±£¬¼´£¬ÊôÓÚÁ½¸ö¼¯ºÏÆä
ÖÐ
Ö®Ò»µÄ³ÉÔ±¡£ÁªºÏ·ûºÅÓÐÒ»¸öµÈ¼ÛµÄ·½·¨£¬union().
Edit By Vheavens
Edit By Vhe ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ