pythonË㷨ʵ¼ù6 ¶ÑÅÅÐò
#¶ÑÅÅÐò
def Heapify(mylist, start, end):
left = 0
right = 0
maxv = 0
left = start * 2
right = start * 2 + 1
while left <= end:
maxv = left
if right <= end:
if mylist[left] < mylist[right]:
maxv = right
else:
maxv = left
if mylist[start] < mylist[maxv]:
tmp = mylist[maxv]
mylist[maxv] = mylist[start]
mylist[start] = tmp
start = maxv
else:
break
left = start * 2
right = start * 2 + 1
def BuildHeap(mylist):
size = len(mylist)
i = (size -1) // 2;
while i >= 0:
Heapify(mylist, i, size - 1)
i = i - 1
def HeapSort(mylist):
BuildHeap(mylist)
i = len(mylist) - 1
while i >= 0:
tmp = mylist[0]
mylist[0] = mylist[i]
mylist[i] = tmp
Heapify(mylist, 0, i - 1)
i = i - 1
mylist0 = [11, 23, 1, 24, 112, 200, 9, 32]
HeapSort(mylist0)
print(mylist0)
Ïà¹ØÎĵµ£º
python µÄÄÚǶtimeÄ£°å·Ò뼰˵Ã÷
Ò»¡¢¼ò½é
timeÄ£¿éÌṩ¸÷ÖÖ²Ù×÷ʱ¼äµÄº¯Êý
˵Ã÷£ºÒ»°ãÓÐÁ½ÖÖ±íʾʱ¼äµÄ·½Ê½:
µÚÒ»ÖÖÊÇʱ¼ä´ÁµÄ·½Ê½(Ïà¶ÔÓÚ1970.1.1 00:00:00ÒÔÃë¼ÆËãµÄÆ«ÒÆÁ¿),ʱ¼ä´ÁÊÇΩһµÄ
µÚ¶þÖÖÒÔÊý×éµÄÐÎʽ±íʾ¼´(struct_time),¹²ÓоŸöÔªËØ£¬·Ö±ð±íʾ£¬Í¬Ò»¸öʱ¼ä´ÁµÄstruct_time»áÒòΪʱÇø²»Í¬¶ø²»Í¬
year ......
python stringºÍPyQtµÄQStringµÄÇø±ð ÒÔÏÂÔÚPython2.6ºÍPyQt4.4.4 for
Python2,6»·¾³ÏÂÌÖÂÛ£º PythonÖÐÓÐÁ½ÖÖÓйØ×Ö·ûµÄÀàÐÍ£ºPython string objectºÍPython Unicode
object¡£Ö÷ҪʹÓÃPython string object½øÐÐÊý¾ÝÊäÈëÊä³ö¡£ PyQtÖÐÓëÖ®Ïà¶ÔÓ¦µÄ×Ö·ûÓйØÀà
python stringºÍPyQtµÄQStringµÄÇø±ð
ÒÔÏÂÔÚPython2.6ºÍPyQt4 ......
Öð²½Ñݽø
f=open('/etc/motd','r')
longest=0
while True:
lineLen=len(f.readline().strip())
if not lineLen: break
if lineLen > longest:
longest=lineLen
f.close()
return longest
ÎÊÌâ£ºÒ»Ö±Õ¼Ó ......
Ê×ÏÈתÔØÒ»¶Î¹ØÓÚÍƼöµÄѧϰpythonµÄÊé¼®£¨ÔÎÄÁ´½Ó£©£º
1.ѧϰ¡¶A Byte of Python¡·£¬ÖÐÎÄÒëÃûΪ¡¶Python¼òÃ÷½Ì³Ì£¨pdfÏÂÔصØÖ·£©¡·£¬È«ÊéÏÂÀ´Ö»ÓÐ100¶àÒ³£¬¼òµ¥¸ÉÁ·£¬Í¨Ë×Ò׶®£¬Êǹ«ÈϵÄPythonÈëÃŽ̡̳£ÎÒËäȻϵ½ÁË¡¶Python¼òÃ÷½Ì³Ì¡·pdf°æ£¬µ«ÊǾõµÃÆäÖеĴúÂë¿ÉÄÜÊÇÒòΪÒëÕßת»»ÎĵµÀàÐ͵ÄÔÒò£¬¸ñʽ±äµÃºÜÂÒ£¬ËùÒÔ× ......
2008-12-21
pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
¹Ø¼ü×Ö: pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
pythonÀàÐÍת»»
Java´úÂë
º¯Êý ÃèÊö
int(x [,base ])   ......