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

python decorator

1.³£Ó÷½·¨£¬²»´ø²ÎÊý
def decator(func):
    def inner_func(*args):
        args = (i * 2 for i in args)
        return func(*args)
    return inner_func
   
@decator
def add(a, b, c):
    return a + b + c
2.´ø²ÎÊý£º
class Dec(object):
    def __init__(self, i):
        self.i = i
    def __call__(self, func):
        def inner_func(a, b, c):
            return self.i * func(a, b, c)
        return inner_func
   
@Dec(2)
def abc(x, y, z):
    print "function abc"
    print (x, y, z)
    return x + y + z


Ïà¹ØÎĵµ£º

ʹÓà Notepad++ ±à¼­ÔËÐÐ Python ³ÌÐò


Posted on 18:40:00 by ÏþÔÂ and filed under Notepad++, Python
¡¡¡¡Notepad++ ÊÇÒ»¸ö¿ªÔ´µÄÎı¾±à¼­Æ÷£¬¹¦ÄÜÇ¿´ó¶øÇÒʹÓ÷½±ã¡£±à¼­ºÍµ÷ÊÔ Python ³ÌÐòʹÓÃʲô±à¼­Æ÷»òÕß IDE ²»Í¬ÈËÓв»Í¬¼û½â¡£ÔÚ²»¿¼ÂÇʹÓõ÷ÊÔ¹¤¾ßµÄÇé¿öÏ£¬Vim »òÕß Emacs Óû§×ÔÈ»¿ÉÒÔÎÞÊÓÆäËû±à¼­Æ÷£¬²»¹ýÔÚ Windows »·¾³Ï£¬Ê¹Óà Notepad++ Ö ......

pythonÖÐMySQLdbµÄ¼òµ¥Ê¹ÓÃ

¶ÔÊý¾Ý¿âµÄ²Ù×÷»ù±¾·ÖΪÈý²½£º
 
Á¬½ÓÊý¾Ý¿â
¸ù¾ÝÐèÒªÖ´ÐÐSQLÓï¾ä£¬½ÓÊÜ·µ»ØÖµ
¹Ø±ÕÁ¬½Ó
ÎÒÃÇÕý³£µÄÊý¾Ý¿âÓ¦¸Ã¶¼Àë²»¿ªÕâÈý²½£¬ÏÂÀ´ËµËµÈçºÎʹÓÃpythonÖеÄMySQLdbÄ£¿é½øÐÐÕâЩ²Ù×÷£º
Ê×ÏÈ£¬ÎÒÃÇÐèÒª°ÑMySQLdbÒýÈëµ½³ÌÐòÖÐ
 
import MySQLdb
 
È»ºó¿ªÊ¼Êý¾Ý¿â²Ù×÷
1.Êý¾Ý¿âÁ¬½Ó
conn = MySQLdb. ......

[Python module] queue

8.8. queue — A synchronized queue class¶
queue -- Ò»¸öͬ²½¶ÓÁÐÀà
The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implemen ......

дÁ˼¸¸öÓйØoperaminimodµÄpythonС³ÌÐò

дÁ˼¸¸öÓйØoperaminimodµÄpythonС³ÌÐò
firefox->opmÊéǩת»»
import re
def pipeiwangzhi(a):
    s=[]
    pp= re.compile(r'<DT><A HREF="(.*)" ADD_DATE=(.*>)(.*)</A>')
    m=pp.search(a)
    s1=[]
  ......

Python: pythonµÄ¼òµ¥±í´ïʽ¼ÆËãÆ÷

ÕâÊÇÒ»¸ö¼òµ¥µÄ±í´ïʽ¼ÆËãÆ÷, ²»Ì«¶®ÓÃTkinterдGUI, ²Î¿¼Á˱ðÈ˵ĴúÂë
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pa ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ