python formatterÄ£¿é
formatter Ä£¿é
formatter Ä£¿éÌṩÁËһЩ¿ÉÓÃÓÚ htmllib µÄ¸ñʽÀà( formatter classes ).
ÕâЩÀàÓÐÁ½ÖÖ, formatter ºÍ writer . formatter ½« HTML ½âÎöÆ÷µÄ±êÇ©ºÍÊý¾ÝÁ÷ת»»ÎªÊʺÏÊä³öÉ豸µÄʼþÁ÷( event stream ), ¶ø writer ½«Ê¼þÁ÷Êä³öµ½É豸ÉÏ.
´ó¶àÇé¿öÏÂ, Äã¿ÉÒÔʹÓà AbstractFormatter Àà½øÐиñʽ»¯. Ëü»á¸ù¾Ý²»Í¬µÄ¸ñʽ»¯Ê¼þµ÷Óà writer ¶ÔÏóµÄ·½·¨. AbstractWriter ÀàÔÚÿ´Î·½·¨µ÷ÓÃʱ´òÓ¡Ò»ÌõÐÅÏ¢.
ʹÓà formatter Ä£¿é½« HTML ת»»ÎªÊ¼þÁ÷
!/usr/bin/python
import formatter
import htmllib
w=formatter.AbstractWriter() ££writer½«Ê¼þÁ÷Êä³öµ½É豸ÉÏ
f=formatter.AbstractFormatter(w) ££formatter½«HTML½âÎöÆ÷µÄ±êÇ©ºÍÊý¾ÝÁ÷ת»»ÎªÊʺÏÊä³öµÄʼþÁ÷
file=open("index.html")
p=htmllib.HTMLParser(f)
p.feed(file.read())
p.close()
file.close()
ÔËÐнá¹û£º
windyang@windyang-desktop:~/python$ python formatter-example-1.py
send_flowing_data('\xa0')
send_line_break()
send_paragraph(1)
new_font(('h1', 0, 1, 0))
send_flowing_data('Dive Into Python')
send_line_break()
send_paragraph(1)
new_font(None)
send_flowing_data('Python from novice to pro')
send_line_break()
send_paragraph(1)
send_flowing_data('Find:')
send_flowing_data('\xa0')
send_line_break()
send_paragraph(1)
new_font(('h2', 0, 1, 0))
new_font(None)
new_font((None, 1, None, None))
send_flowing_data('Dive Into')
send_flowing_data(' Python')
new_font(None)
send_flowing_data(' is a free')
send_flowing_data(' Python')
send_flowing_data(' book for experienced programmers. You can')
send_flowing_data(' read the book')
send_flowing_data('[1]')
send_flowing_data(' online, or')
send_flowing_data(' download it')
send_flowing_data('[2]')
send_flowing_data(' in a variety of formats. It is also available in')
send_flowing_data(' multiple languages')
send_flowing_data('[3]')
send_flowing_data('.')
send_line_break()
send_paragraph(1)
new_font(('h2', 0, 1, 0))
send_flowing_data('Read')
send_flowing_data(' ')
new_font(('h2', 1, 1, 0))
send_flowing_data('Dive Into')
send_flowing_data(' Python')
new_fo
Ïà¹ØÎĵµ£º
ΪÁËÈÃUEÖ§³ÖpythonÓïÑÔ£¬googleÁ˺ܶ࣬½á¹û¶¼²»ÐУ¬×îºó¿´ÁËÏÂÃæµÄ²©¿Í²ÅÖªµÀ´íÄÄÁË£¬×ܽáÏÂÒÔÃâÍü¼Ç¡£
http://wangtao.name/2009/12/20/ultraedit_python.html
ÔÚ¹ÙÍøÉÏÕÒµ½pythonµÄÀ©Õ¹ÏÂÔØµã£ºhttp://www.ultraedit.com/downloads/extras.html
Óи÷ÖÖÓïÑÔµÄÀ©Õ¹£¬±ã¿ÉÒÔÖ§³ÖÓï·¨¸ßÁÁ¡£
python 2.5£ºhttp://www.u ......
½ñÌìÊÔÑéʹÓÃpythonÁ¬½Ó sql server ·þÎñÆ÷¡£ÎҼǵÃÒÔǰʹÓÃadoÁ¬½Óaccess·Ç³£Ë³Àû£¬µ«ÊǽñÌìʹÓÃadoÁ¬½Ósql server¾¹È»²»³É¹¦¡£ÔÚpythonÀïÃæµÄ³ö´íÐÅÏ¢¶¼ÏÔÊ¾Îª×ªÒÆÐòÁУ¬·ÑÁ˰ëÌì¾¢²Å¸ãÃ÷°×£ºÎÞЧµÄÀà±ð×Ö·û´®¡£
ÊÇÁ¬½Ó×Ö·û´®Â𣿲âÊÔÁ˺ü¸¸ö È·ÈÏÎÞÎóµÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬Ò²ÊÇÈç´Ë ¡£ÉÏÍøËÑË÷£¬ÊÇÓпÉÄÜÊÇ comµÄÀà±ð×Ö ......
1¡¢Ê¹ÓÃdef¶¨Ò庯Êý
2¡¢º¯ÊýÎĵµ£ºÔÚº¯ÊýµÄ¿ªÍ·Ð´ÏÂ×Ö·û´®£¬Ëü¾Í»á×÷Ϊº¯ÊýµÄÒ»²¿·Ö½øÐд洢£¬³ÆÎª"Îĵµ×Ö·û´®"¡£
ÄÚ½¨µÄ½Ð×öhelpµÄº¯Êý·Ç³£ÓÐÓÃ,Èç¹ûÄãÔÚ½»»¥Ê½½âÊÍÆ÷ÖÐʹÓã¬Äã¿ÉÒԵõ ......
Python ÓÃÏ»®Ïß×÷Ϊ±äÁ¿Ç°×ººÍºó׺ָ¶¨ÌØÊâ±äÁ¿¡£
_xxx
²»ÄÜÓÃ'from module import *'µ¼Èë
__xxx__ ϵͳ¶¨ÒåÃû×Ö
__xxx
ÀàÖеÄ˽ÓбäÁ¿Ãû
ºËÐÄ·ç¸ñ£º±ÜÃâÓÃÏ»®Ïß×÷Ϊ±äÁ¿ÃûµÄ¿ªÊ¼¡£
ÒòΪÏ»®Ïß¶Ô½âÊÍÆ÷ÓÐÌØÊâµÄÒâÒ壬¶øÇÒÊÇÄÚ½¨±êʶ·ûËùʹÓõķûºÅ£¬ÎÒÃǽ¨Òé³ÌÐò ......