Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : Python

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

Ê×ÏÈתÔØÒ»¶Î¹ØÓÚÍƼöµÄѧϰpythonµÄÊé¼®£¨Ô­ÎÄÁ´½Ó£©£º
1.ѧϰ¡¶A Byte of Python¡·£¬ÖÐÎÄÒëÃûΪ¡¶Python¼òÃ÷½Ì³Ì£¨pdfÏÂÔصØÖ·£©¡·£¬È«ÊéÏÂÀ´Ö»ÓÐ100¶àÒ³£¬¼òµ¥¸ÉÁ·£¬Í¨Ë×Ò׶®£¬Êǹ«ÈϵÄPythonÈëÃŽ̡̳£ÎÒËäȻϵ½ÁË¡¶Python¼òÃ÷½Ì³Ì¡·pdf°æ£¬µ«ÊǾõµÃÆäÖеĴúÂë¿ÉÄÜÊÇÒòΪÒëÕßת»»ÎĵµÀàÐ͵ÄÔ­Òò£¬¸ñʽ±äµÃºÜÂÒ£¬ËùÒÔ×¼±¸¾¡Á¿ÔĶÁÓ¢ÎÄÔ­°æ¡£ÍøÂçÉÏÒ²ÓС¶Python¼òÃ÷½Ì³Ì¡·µÄword°æ£¬²»Ïë¿´Ó¢ÎĵÄÅóÓÑ¿ÉÒÔÕÒһϡ£ 
2.ÎÒÂòÁËÒ»±¾Ó°Ó¡°æµÄ¡¶Learning Python¡·µÚÈý°æ£¬ÓÃÓÚ¾«¶Á¡£ÏÖÔÚÄÜÂòµ½µÄ°æ±¾±È½ÏеÄPython¾­µäÊé¼®Ò»¹²ÓÐÁ½±¾£¬Ò»±¾ÊÇ¡¶Learning Python¡·µÚÈý°æ£¬Ò»±¾ÊÇ¡¶PythonºËÐıà³Ì¡·µÚ¶þ°æ¡£±¾À´ÊÇÏëÂòºóÕߵģ¬ÒòΪ¿´ÖÐÎıϾ¹Òª±È¿´Ó¢ÎÄÀ´µÄ¿ìһЩ£¬²»¹ý¿´ÁËÏÂÊéÆÀ£¬¡¶PythonºËÐıà³Ì¡·µÚ¶þ°æ¾ÓÈ»ÊÇÒ»¸ö½ÐËÎX¹ãµÄIT°ÜÀà°ÑCPUGÂÛ̳ÉÏ´ó¼Ò¹²Í¬·­ÒëµÄ³É¹ûռΪ¼ºÓУ¬ÊôÉÏÁË×Ô¼ºµÄÃû×Ö£¡£¨Ïêϸʼþ¾­¹ý¿ÉÒÔ¿´china-pub»òÕßdangdang¶ÔÕâ±¾ÊéµÄµãÆÀ£¬Ò²¿ÉÒÔ¿´ÕâÀïhttp://groups.google.com/group/python-cn/browse_thread/thread/e5e465336fdeb03c?hl=zh-CN£©ÎÒ¾õµÃÈç¹ûÊÇÂòÕâ±¾Ê飬ÈÃÕâÑùµÄÈË׬ȡ¸å·Ñ£¬Ì«²»ÖµµÃÁË£¬ËùÒÔÍ˶øÇóÆä´Î£¬ÂòÁ˱¾Ó°Ó¡°æµÄ¡¶Learning Pyt ......

pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷


2008-12-21
pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
¹Ø¼ü×Ö: pythonÀàÐÍת»»¡¢ÊýÖµ²Ù×÷
pythonÀàÐÍת»»
Java´úÂë
º¯Êý                      ÃèÊö   
int(x [,base ])         ½«xת»»ÎªÒ»¸öÕûÊý   
long(x [,base ])        ½«xת»»ÎªÒ»¸ö³¤ÕûÊý   
float(x )               ½«xת»»µ½Ò»¸ö¸¡µãÊý   
complex(real [,imag ])  ´´½¨Ò»¸ö¸´Êý   
str(x )                 ½«¶ÔÏó x ×ª»»Îª×Ö·û´®   
repr(x )                ½«¶ÔÏó x ×ª»»Îª±í´ïʽ×Ö·û´®  & ......

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__ definitions
# the Vector object can be considered a list
# the lambda function adds each other item to each item in the list
# note this only adds objects that can typicaly be added by python
# print statements added to show what is getting called
class Vector:
def __init__(self, data):
print "__init__"
self.data = data
def __call__(self, varA, varB):
print "__call__"
print "do something with ", varA, " and ", varB
# overload print
# repr returns a string containing a printable representation of an object
# otherwise printing a Vector object would look like:
#<__main__.Vector instance at 0x0000000017A9DF48>
def __ ......

python×ÖµäÅÅÐò

python×ÖµäÅÅÐò
1¡¢ 
×¼±¸ÖªÊ¶£º
ÔÚpythonÀ×ÖµädictionaryÊÇÄÚÖõÄÊý¾ÝÀàÐÍ£¬ÊǸöÎÞÐòµÄ´æ´¢½á¹¹£¬Ã¿Ò»ÔªËØÊÇkey-value¶Ô£º
È磺dict = {‘username’£º‘password’£¬‘database’£º‘master’}£¬ÆäÖБusername’ºÍ‘database’ÊÇkey£¬¶ø‘password’ºÍ‘master’ÊÇvalue£¬¿ÉÒÔͨ¹ýd[
key
]»ñµÃ¶ÔÓ¦ÖµvalueµÄÒýÓ㬵«ÊDz»ÄÜͨ¹ývalueµÃµ½key¡£
¶ÔÓÚdictionnary£¬ÐèÖªµÀÒÔϼ¸µã×¢ÒâÊÂÏ
a¡¢ 
dictionary µÄ key ÊÇ´óСдÃô¸ÐµÄ
£»
b¡¢ 
Ò»¸ödictionaryÖв»ÄÜÓÐÖظ´µÄ key
£»
c¡¢ 
d
ictionary
ÊÇÎÞÐòµÄ£¬Ã»ÓÐÔªËØ˳ÐòµÄ¸ÅÄ
ËüÃÇÖ»ÊÇÐòżµÄ¼òµ¥ÅÅÁÐ
¡£
 
 
2¡¢ 
×ÖµäÅÅÐòʵÏÖ£º
²Î¼ûcookbook£¬
Recipe 5.1. Sorting a Dictionary
½²ÊöÁË×ÖµäÅÅÐòµÄ·½·¨£»
Ç°ÃæÒÑ˵Ã÷d
ictionary
±¾ÉíûÓÐ˳Ðò¸ÅÄµ«ÊÇ×ÜÊÇÔÚijЩʱºò£¬µ«ÊÇÎÒÃdz£³£ÐèÒª¶Ô×Öµä½øÐÐÅÅÐò£¬Ôõô×öÄØ£¿ÏÂÃæ¸æËßÄ㣺
·½·¨1£º
×î¼òµ¥µÄ·½·¨£¬
ÅÅÁÐÔªËØ£¨key/value¶Ô£ ......

pythonË㷨ʵ¼ù1 Ö±½Ó²åÈëÅÅÐò

# Ö±½Ó²åÈëÅÅÐò
def InsertSort(mylist):
size = len(mylist)
i = 1
for i in range(1, size):
if mylist[i] < mylist[i - 1]:
tmp = mylist[i]
j = i - 1
mylist[j + 1] = mylist[j]

j = j - 1
while j >= 0 and mylist[j] > tmp:
mylist[j + 1] = mylist[j]
j = j - 1
mylist[j + 1] = tmp
mylist0 = [12, 11, 13, 1, 2, 4, 3]
InsertSort(mylist0)
print(mylist0)
 
......

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] > tmp:
mylist[j + d] = mylist[j]
j = j - d
mylist[j + d] = tmp
i = i + d
def ShellSort(mylist):
n = len(mylist)
while n > 1:
n = n // 3 + 1
ShellPass(mylist, n)

mylist0 = [12, 11, 13, 1, 2, 4, 3, 77, 44]
ShellSort(mylist0)
print(mylist0)
  ......
×ܼǼÊý:695; ×ÜÒ³Êý:116; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [28] [29] [30] [31] 32 [33] [34] [35] [36] [37]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ