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µÄµÀ·ÂþÂþ£¬¹â¿´²»Á·±È½ÏÎÞÁÄ¡£
ÕÒÁ˸öÍøÒ³£¬ÉÏÃæÓм¸µÀÏ°Ì⣬ÎÞÁÄÖ®ÓàÄÃÀ´Á·ÊÖ£¬»¹ÓÐЩÀÖȤ¡£
ÊÇÕâÀhttp://www.cnblogs.com/belaliu/archive/2006/11/25/572140.html
×¢£ºÏ°ÌâºóÃæÌùµÄ´úÂë²»Ò»¶¨ÊÇ×îÓŵġ£
´ó²¿·Ö±È½ÏºÃ½â¾ö£¬ÓеãÄѶȵÄÊǵÚ4Ìâ×öÈ¥³ý×Ö·û´®ÄڵĿոñµÄ²Ù×÷¡£
ÕÒÁËÍøÉϵĽâ¾ö·½°¸£¬ÓÐÕâ ......
ż¶û×ö¸ö¼òµ¥µÄWEB·þÎñ²âÊÔ³ÌÐò£¬ÎÒ»¹ÊÇϲ»¶²ÉÓÃPHP¡£¼ò½à£¬·ç¸ñºÍC/C++½Ó½ü£¬ÉÏÊֿ죬¶øÇÒ¿âÒ²ºÜÆëÈ«¡£ÒÔǰΪ¹ã¶«Òƶ¯×öÒƶ¯ÐÐÒµÖն˵ÄÑÝʾ³ÌÐòʱ£¬²ÉÓùúÄÚÒ»¸öÐÖµÜдµÄFleaPHP¿ªÔ´¿ò¼Ü£¬Á½Öܲ»µ½µÄʱ¼ä£¬ÎÒ´ÓÒ»¸ö¶ÔPHPÒ»ÎÞËùÖªµÄˮƽ£¬¿ìËٵĸ㶨ÁË30¶à¸öÒ³ÃæµÄºǫ́£¬ºóÀ´ÑÝʾЧ¹ûÒ²²»´í£¬Ò²ºÜÎȶ¨£¬´Ó´Ë¶ÔPHPÓÐÁ ......
½ñÌì×öftpµÄ½çÃæ,×öµÄÏ൱ÓôÃÆ£¬ÅªµÃÐÄÇé¼°Æ䲻ˬ£¬ÔÚÍøÉÏËѵ½ËÀ¶¼²»ÖªµÀ¸ÃÔõô°ì£¬´òËãÃ÷ÌìÏÈ¿´¿´C£«£«
µÄÊÇÔõôŪµÄÔÙ˵¡£²»¹ý£¬ÏÖÔÚÎÒÏëдһϹØÓÚsocketµÄ±à³Ì¡£
ÏÈдһ¸öʱ¼ä·þÎñÆ÷°É£¬Ëû¼àÌý¶Ë¿Ú£¬²¢Çһ᷵»Ø ·þÎñÆ÷µÄʱ¼ä
server.py
#!/usr/bin/python
# Copyright (c) angelipin (angelipin@126.com)
import ......
ZoundryDocument
Python skin is known for its color variations and for its elasticity; it is
the warmest leather of the season and ideal for the manufacture of many luxury
goods. Sometimes natural patterns can be hidden when they're done in black, but
the finish here has a bit of a shine to it ......
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......