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

pythonË㷨ʵ¼ù7 ¹é²¢ÅÅÐò

def MergeSort(mylist, low, mid, high):
i = low
j = mid + 1
tmp = []

while i <= mid and j <= high:
if mylist[i] <= mylist[j]:
tmp.append(mylist[i])
i = i + 1
else:
tmp.append(mylist[j])
j = j + 1

while i <= mid:
tmp.append(mylist[i])
i = i + 1
while j <= high:
tmp.append(mylist[j])
j = j + 1
for k in range(low, high):
mylist[k] = tmp[k]

mylist0 = [1, 3, 5, 7, 9, 11, 6, 8, 66, 88, 100]
MergeSort(mylist0, 0, 5, len(mylist0) - 1)
print(mylist0)


Ïà¹ØÎĵµ£º

python stringºÍPyQtµÄQStringµÄÇø±ð

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 ......

Ç¿´óµÄPythonÉú³ÉÆ÷

Öð²½Ñݽø
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 ʹÓÃC´úÂë——swig

Ref : http://www.swig.org/translations/chinese/tutorial.html
¼ÙÉèÄãÓÐһЩcÄãÏëÔÙ¼ÓPython.¡£¾ÙÀýÀ´ËµÓÐÕâôһ¸öÎļþexample.c
 /* File : example.c */
 #include <time.h>
 double My_variable = 3.0;
 int fact(int n) {
     if (n <= 1) return 1;
&nbs ......

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Ë㷨ʵ¼ù3 ðÅÝÅÅÐò

#ðÅÝÅÅÐò
def BubbleSort(mylist):
n = len(mylist)
i = 0
j = 0
bExchange = False
for i in range(1, n):
bExchange = False
j = n - 1
while j >= i:
if mylist[j] < mylist[j - 1]:
tmp = mylist[j]
myli ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ