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

Python: ʹÓÃ×°ÊÎÆ÷¡°@¡±È¡µÃº¯ÊýÖ´ÐÐʱ¼ä

¡¡¡¡PythonÖпÉÒÔʹÓÃ×°ÊÎÆ÷¶Ôº¯Êý½øÐÐ×°ÊΣ¨»ò˵°ü×°£©£¬ÀûÓÃÕâ¸öÌØÐÔ£¬¿ÉÒԺܷ½±ã¡¢¼ò½àµØ½â¾öһЩÎÊÌ⣬±ÈÈç»ñµÃº¯ÊýÖ´ÐÐʱ¼äµÄÎÊÌâ¡£
¡¡¡¡Ê×ÏÈ£¬ÎÒÃǶ¨ÒåÒ»¸öº¯Êý£¬ÈçÏ£º
¡¡¡¡def exeTime(func):
def newFunc(*args, **args2):
t0 = time.time()
print "@%s, {%s} start" % (time.strftime("%X", time.localtime()), func.__name__)
back = func(*args, **args2)
print "@%s, {%s} end" % (time.strftime("%X", time.localtime()), func.__name__)
print "@%.3fs taken for {%s}" % (time.time() - t0, func.__name__)
return back
return newFunc

¡¡¡¡µ±È»£¬²»ÒªÍüÁË“import time”µ¼ÈëtimeÄ£¿é¡£Õâ¸öº¯Êý¾Í¿ÉÒÔÓÃ×÷ÎÒÃǼÆË㺯ÊýÖ´ÐÐʱ¼äµÄÐÞÊÎÆ÷ÁË¡£
¡¡¡¡½ÓÏÂÀ´£¬ÎÒÃǾͿÉÒÔÔÚÐèÒª¼ÆʱµÄº¯ÊýÇ°Ò»ÐÐÒýÓÃËü×÷ΪװÊΣ¬±ÈÈ磺
¡¡¡¡@exeTime
def foo():
for i in xrange(10000000):
pass
¡¡¡¡×¢Òâ×îÉÏ·½µÄ“@exeTime ”£¬×°ÊÎÆ÷µÄÓï·¨ÒÔ“@”¿ªÍ·£¬½Ó×ÅÊÇ×°Êκ¯Êý£¬ÔÚ±¾ÀýÖÐΪ“exeTime”¡£Õâʱ£¬Ö´Ðк¯Êýfoo£¬×°ÊÎÆ÷¾Í»áÔÚ¿ØÖÆ̨´òÓ¡³öÕâ¸öº¯ÊýµÄÖ´ÐÐʱ¼äÁË¡£
¡¡¡¡ÍêÕû´úÂëÈçÏ£º
¡¡¡¡# -*- coding: utf-8 -*-
import time
# --exeTime
def exeTime(func):
def newFunc(*args, **args2):
t0 = time.time()
print "@%s, {%s} start" % (time.strftime("%X", time.localtime()), func.__name__)
back = func(*args, **args2)
print "@%s, {%s} end" % (time.strftime("%X", time.localtime()), func.__name__)
print "@%.3fs taken for {%s}" % (time.time() - t0, func.__name__)
return back
return newFunc
# --end of exeTime
@exeTime
def foo():
for i in xrange(10000000):
pass
if __name__ == "__main__":
foo()
¡¡¡¡ÔÚ±ÊÕßµçÄÔÉϵÄÔËÐнá¹ûΪ£º
@13:12:27, {foo} start
@13:12:27, {foo} end
@0.203s taken for {foo}
¡¡¡¡µ±È»£¬ÉÏÃæÖ»ÊÇÒ»¸öºÜ¼òµ¥µÄʾÀý£¬ÊÂʵÉÏ£¬±¾ÀýÖеÄ×°ÊÎÆ÷exeTime²»½ö¿ÉÒÔ×°ÊÎÀàËÆÉÏÃæ“foo”ÕâÑù²»´ø²ÎÊýµÄº¯Êý£¬Ò²ÄÜ×°ÊδøÈÎÒâ²ÎÊýµÄº¯Êý£¬ÉõÖÁ»¹¿ÉÒÔ×°ÊÎÀàµÄ·½·¨£¬Ó÷¨ÓëÉÏÃæÊÇÒ»ÑùµÄ¡£
¡¡¡¡³ýÁ˼ÆËãÔËÐÐʱ¼äÍ⣬װÊÎÆ÷»¹¿ÉÒÔÓкܶàÓÃ;£¬±ÈÈç¼Ç¼ÔËÐÐÈÕÖ¾µÈ£¬¸ü¶àµÄÓÃ;µÈ´ý¸ü¶àµÄÅóÓÑÈ¥·¢¾ò¡£


Ïà¹ØÎĵµ£º

python±È½Ï²Ù×÷µÄÄÚÄ»

½ñÌì¿´ÁËÐòÁÐÀàÐÍÏà¹ØµÄ±È½Ï²Ù×÷.
ÔÚpythonºËÐıà³Ì(2nd)Ò»ÊéÖÐ6.13.1Õ½ÚÖÐ, ¸ø³öÁËÁбí±È½ÏµÄÒ»¸ö×¼Ôò..
¸öÈ˸оõ»¹ÊDz»ºÜÍêÉÆ:
Èç¹ûɨÃèµ½Á½¸öÁбíÖе±Ç°±È½ÏÔªËØÊDz»¿É±È½ÏµÄ, ÄÇô·µ»Øʲô??
ÎÒÓõÄÊÇpython2.6....
¶ÔÕâ¸öÎÊÌâ×öÁËһЩ²âÊÔ, ×Ô¼ºÄ¿Ç°¸Â¾øµ±±È½ÏÓöµ½ÉÏÊöÇé¿öʱ, ÊÇʹÓÃÁ½¸öÁбíµÄÄÚ´æµØÖ·ÖµÀ´±È½ ......

python±Ê¼ÇÖ®ÕýÔò±í´ïʽ

 ÕýÔò±í´ïʽ
¾ßÌåµÄ²Î¿¼ÊֲᣬÕâÀï¼ÇÏÂһЩСÎÊÌ⣺
1¡¢re¶ÔÏóµÄ·½·¨
match    Match a regular expression pattern to the beginning of a string.
search   re.search(pattern, string, flags) flags:re.I re.M re.X re.S re.L re.U
sub      Substitute oc ......

Python GUI

1. ʼþÇý¶¯
    Ò»¸öʼþ¼°Æä»Øµ÷µÄÀý×ÓÊÇÊó±êÒƶ¯¡£ÎÒÃǼÙÉèÊó±êÖ¸ÕëÍ£ÔÚÄúGUI ³ÌÐòµÄij´¦¡£Èç¹ûÊó±ê±»ÒƵ½Á˳ÌÐòµÄ±ð´¦£¬Ò»¶¨ÊÇÓÐʲô¶«Î÷ÒýÆðÁËÆÁÄ»ÉÏÖ¸ÕëµÄÒƶ¯£¬´Ó¶ø±íÏÖÕâÖÖλÖõÄתÒÆ¡£ÏµÍ³±ØÐë´¦ÀíÕâЩÊó±êÒƶ¯Ê¼þ²ÅÄÜÕ¹ÏÖ£¨²¢ÊµÏÖ£©Êó±êÔÚ´°¿ÚÉϵÄÒƶ¯¡£Ò»µ©ÄúÊÍ·ÅÁËÊó±ê£¬¾Í²»ÔÙ»áÓÐʼþÐèÒª´¦ ......

³ÌÐò python ץȡÐÂÀ˶ÁÊéƵµÀС˵

¶þ½øÖÆÎļþÏÂÔصØÖ·£º
SinaGetBook
Ч¹ûÈçͼ£º
´úÂ룺
#!/usr/bin/env python
#coding=utf-8
#!/usr/bin/env python
#coding=utf-8
import traceback
import sys
import wx
import re
import urllib
import wx.richtext as rt
import wx.lib.buttonpanel as bp
import Casing
import Debug
def trace_back ......

(ת) pythonÓ¦ÓÃÁìÓò½éÉÜ

#---------------------תתתתתתתתתתתתתתתתתתתתתתת-------------------------------------------#
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
 
¡¡¡¡ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ