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__
Ïà¹ØÎĵµ£º
ʵÑé»·¾³£ºwindows xp + vim
Îļþ£ºtest.py¡£±àÂ룺ansi
ÎÒÃǵÄÄ¿±ê²Ù×÷test.pyÖб£´æµÄ·ÇÓ¢ÎÄ×Öĸ¡£
ÎļþÍ·µÄ#encoding=utf8/gbk£¬Õâ¸öÊÇÓÃÀ´ËµÃ÷Ô´ÎļþµÄÓ²Å̱àÂëÒÔ±ãpythonʶ±ð[4]¡£
----------------------------------------------
ÊäÈë:
x = 'ÖÐÎÄ'
Êä³ö: ±àÒëʧ°Ü
±àÒëʱÐèÒªÖªµÀ‘ÖÐÎÄ’µÄÓ²Å̱à ......
Ê×ÏÈתÔØÒ»¶Î¹ØÓÚÍƼöµÄѧϰpythonµÄÊé¼®£¨ÔÎÄÁ´½Ó£©£º
1.ѧϰ¡¶A Byte of Python¡·£¬ÖÐÎÄÒëÃûΪ¡¶Python¼òÃ÷½Ì³Ì£¨pdfÏÂÔصØÖ·£©¡·£¬È«ÊéÏÂÀ´Ö»ÓÐ100¶àÒ³£¬¼òµ¥¸ÉÁ·£¬Í¨Ë×Ò׶®£¬Êǹ«ÈϵÄPythonÈëÃŽ̡̳£ÎÒËäȻϵ½ÁË¡¶Python¼òÃ÷½Ì³Ì¡·pdf°æ£¬µ«ÊǾõµÃÆäÖеĴúÂë¿ÉÄÜÊÇÒòΪÒëÕßת»»ÎĵµÀàÐ͵ÄÔÒò£¬¸ñʽ±äµÃºÜÂÒ£¬ËùÒÔ× ......
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_ ......
#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] > ......
#Ö±½ÓÑ¡ÔñÅÅÐò
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]
......