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

Python ×ÖµäʹÓÃÀý×Ó


#!/usr/bin/env python
#coding=utf-8
def buildConnectionString(params):
    return ":".join(["%s=%s" %(k, v) for k, v in params.items()])
if __name__ == "__main__":
    myParams = {"server":"mpilgrim", \
                "database":"master", \
                "uid":"sa", \
                "pwd":"secret"\
                }
    print buildConnectionString(myParams)
    print __name__


Ïà¹ØÎĵµ£º

¹ØÓÚpython unicodeµÄʵÑé

ʵÑé»·¾³£ºwindows xp + vim
Îļþ£ºtest.py¡£±àÂ룺ansi
ÎÒÃǵÄÄ¿±ê²Ù×÷test.pyÖб£´æµÄ·ÇÓ¢ÎÄ×Öĸ¡£
ÎļþÍ·µÄ#encoding=utf8/gbk£¬Õâ¸öÊÇÓÃÀ´ËµÃ÷Ô´ÎļþµÄÓ²Å̱àÂëÒÔ±ãpythonʶ±ð[4]¡£
----------------------------------------------
ÊäÈë:
x = 'ÖÐÎÄ'
Êä³ö: ±àÒëʧ°Ü
±àÒëʱÐèÒªÖªµÀ‘ÖÐÎÄ’µÄÓ²Å̱à ......

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

pythonË㷨ʵ¼ù5 Ö±½ÓÑ¡ÔñÅÅÐò

#Ö±½ÓÑ¡ÔñÅÅÐò
def SelectSort(mylist):
size = len(mylist)
i = 0
for i in range(0, size):
k = i
for j in range(i + 1, size):
if mylist[j] < mylist[k]:
k = j

if k != i:
tmp = mylist[i]
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ