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

pythonË㷨ʵ¼ù4 ¿ìËÙÅÅÐò

#¿ìËÙÅÅÐò
def Partition(mylist, low, high):
tmp = mylist[low]
while low < high:
while low < high and mylist[high] >= tmp:
high = high - 1
if low < high:
mylist[low] = mylist[high]
low = low + 1
while low < high and mylist[low] <= tmp:
low = low + 1
if low < high:
mylist[high] = mylist[low]
high = high - 1
mylist[low] = tmp
return low
def QuickSort(mylist, low, high):
if low < high:
pivotpos = Partition(mylist, low, high)
QuickSort(mylist, low, pivotpos - 1)
QuickSort(mylist, pivotpos + 1, high)
mylist0 = [11, 10, 3, 12, 33, 1000, 1, 333, -11]
QuickSort(mylist0, 0, len(mylist0) - 1)
print(mylist0)


Ïà¹ØÎĵµ£º

pythonÖÐdatetimeµÄ±È½Ï·½·¨Ê¹ÓÃ


pythonÖеÄdatetime moduleÊÇרÃÅ´¦Àíʱ¼äÏà¹ØÄÚÈݵÄÄ£¿é,¹¦ÄܺÜÇ¿´ó,µ«ÊÇ·´¶øÏԵñȽϸ´ÔÓ¡£
һϴúÂëÊÇÓÃÀ´Çó´ÓmysqlÖÐÈ¡µ½µÄtimestampºÍµ±Ç°Ê±¼ä±È½Ï£¬Çóʱ¼ä²îµÄ·½·¨
import datetime
lasttime=a.get_last_timestamp(sid=40)[-1]["last_time"] #È¡µ½timestamp
delta = datetime.datetime.now()-lasttime   # ......

Python MySqlDB Ôöɾ¸ÄÊý¾Ý¿â


ÏÂÔØ°²×°MySQLdb
http://sourceforge.net/projects/mysql-python/ ºÃÏñû¿´µ½windows°æ±¾for python2.6µÄÏÂÔØ£¬ÍøÉÏËÑË÷µ½Ò»¸ö
http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
°²×°ºóimport MySQLdb»á³öÏÖ DeprecationWarning: the sets module is deprecated ÕâÑùÒ»¸ö¾¯¸æ£¬googleÖ®
......

pythonѧϰ±Ê¼Ç£¨Ò»£©

Ê×ÏÈ×ªÔØÒ»¶Î¹ØÓÚÍÆ¼öµÄѧϰpythonµÄÊé¼®£¨Ô­ÎÄÁ´½Ó£©£º
1.ѧϰ¡¶A Byte of Python¡·£¬ÖÐÎÄÒëÃûΪ¡¶Python¼òÃ÷½Ì³Ì£¨pdfÏÂÔØµØÖ·£©¡·£¬È«ÊéÏÂÀ´Ö»ÓÐ100¶àÒ³£¬¼òµ¥¸ÉÁ·£¬Í¨Ë×Ò×¶®£¬Êǹ«ÈϵÄPythonÈëÃŽ̡̳£ÎÒËäȻϵ½ÁË¡¶Python¼òÃ÷½Ì³Ì¡·pdf°æ£¬µ«ÊǾõµÃÆäÖеĴúÂë¿ÉÄÜÊÇÒòΪÒëÕßת»»ÎĵµÀàÐ͵ÄÔ­Òò£¬¸ñʽ±äµÃºÜÂÒ£¬ËùÒÔ× ......

example of python operator overloadind

And last here is the overload operators example:
# map() takes two (or more) arguments, a function and a list to apply the function to
# lambda can be put anywhere a function is expected
# map() calls lambada for every element in the self list
# since Vector has overloaded __getitem__ and __len_ ......

pythonË㷨ʵ¼ù2 shellÅÅÐò

#shellÅÅÐò
def ShellPass(mylist, d):
size = len(mylist)
i = d
while i < size:
if mylist[i] < mylist[i - d]:
tmp = mylist[i]
j = i - d
mylist[j + d] = mylist[j]
j = j - d
while j >= 0 and mylist[j] > ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ