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

PythonµÄ×Öµä²Ù×÷

 
PythonµÄ×Öµä²Ù×÷
PythonÌṩÁ˶àÖÖÓ¦ÓÃÓÚ×ÖµäµÄ²Ù×÷¡£ÒòΪ×ÖµäΪÈÝÆ÷£¬ÄÚ½¨lenº¯Êý¿ÉÒÔ½«×ֵ䵱×÷µ¥Ò»²ÎÊýʹÓÃÌýÇзµ»Ø×Öµä¶ÔÏóÖÐÏîÄ¿£¨¼ü£¯Öµ¶Ô£©µÄÊýÄ¿¡£
×Öµä»áÔ±
ÔÚPython2.2ÒÔ¼°ºóÃæ°æ±¾£¬DÖеÄkÔËËã·û¼ì²âÊÇ·ñ¶ÔÏókÊÇ×ÖµäDÖеļü¡£Èç¹ûÊÇ·µ»ØTrueÈç¹û²»ÊÇ·µ»ØFalse¡£ÏàËÆµÄ£¬
Ë÷ÒýÒ»¸ö×Öµä
×ÖµäDÖеÄÖµÓëÏà¹ØµÄ¼ük±»Ë÷Òý±íʾΪ£ºD[k]¡£Ë÷Òý×ÖµäûÓеļü»áÒýÆðÒâÍâ¡£ÀýÈ磺
d = { 'x':42, 'y':3.14, 'z':7 } 
d['x']                          
# 42
d['z']                          
# 7
d['a']                          
# raises exception
ƽÕû¸³Öµµ½Ò»¸öʹÓû¹²»ÔÚ×ÖµäÖеļüµÄË÷Òý£¨ÀýÈ磬D[newkey]=value£©ÊÇÒ»¸ö¿ÉÐеIJÙ×÷£¬¸Ã²Ù×÷¼ÓÔØ¼üºÍÖµµ½×ÖµäÀïеÄÏîÄ¿ÖС£ÀýÈ磺
d = { 'x':42, 'y':3.14, 'z':7 } 
d['a'] =
16                     
# d is now {'x':42,'y':3.14,'z':7,'a':16}
del
D[k]ÖеÄdelÓï¾ä£¬É¾³ý×ÖµäÖÐÓµÓмükµÄÏîÄ¿¡£Èç¹ûk²»ÊÇ×ÖµäDÖеļü£¬del
D[k]¾Í»áÒýÆðÒâÍâ¡£
×ֵ䷽·¨
×Öµä¶ÔÏóÌṩÁ˶àÖÖ·½·¨£¬Èçϱí¸ñËùʾ¡£·Ç±äÒì·½·¨·µ»Ø½á¹û£¬µ«²»¸Ä±äËüÃÇʹÓõĶÔÏó¡£ÔÚÏÂÃæÁбíÖУ¬DºÍD1´ú±íÈκÎ×Öµä¶ÔÏó£¬k´ú±íDÖÐÈκÎÓÐЧµÄ¼ü£¬xΪÈκζÔÏó¡£
·½·¨
ÃèÊö
Non-mutating methods
D.copy( )
Returns a (shallow) copy of the dictionary
D.has_key(k)
Returns True if k is a key in D, otherwise returns False
D.items( )
Returns a copy of the list of all items (key/value pairs) in
D
D.keys( )
Returns a copy of the list of all keys in D
D.values( )
Returns a copy of the list of all values in D
D.iteritems( )
Returns an iterator on all items(key/value pairs) in D
D.iterkeys( )
Returns an iterator o


Ïà¹ØÎĵµ£º

ÔÚPythonÖж¯Ì¬°ó¶¨property

 ÔÚPythonÖпÉÒÔ°Ñproperty¶¯Ì¬µÄ°ó¶¨µÄobjectµÄ¼Ì³ÐÀàÖУ¬²¢ÇÒ¿ÉÒÔ¶¨Òå´øÓвÎÊýµÄgetºÍset·½·¨¡£
±ÈÈ磬ÎÒÃǶ¨ÒåÁËÈ«¾Ö±äÁ¿g£¬È»ºóͨ¹ýÁ½¸ö·½·¨À´´æÈ¡gµÄÄÚÈÝ
def get_g(self):
    return g
def set_g(self, _g):
    global g
    g = _g
¶¨ÒåÒ»¸öobjectµÄ¼Ì³ ......

PEP 0263 Defining Python Source Code Encodings

 
PEP 0263
Defining Python Source Code Encodings
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, suc ......

eat python 003

Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is posi ......

opencv python cool

µ±Äê×ö±ÏÒµÂÛÎĵÄʱºòopenCV¾ÍÏñÊÇÎÒµÄÈðÊ¿¾üµ¶£¬Ì«ÓиÐÇéÁË¡£Èç½ñÓÃÁËÒ»Äê¶àµÄpython£¬·¢ÏÖopenCVÒ²ÓÐpython°æ±¾ÁË£¬ÕæÊÇÌ«¿áÁË£¡µ±È»pythonÔÚ´¦ÀíͼÏñʱ»¹¿ÉÒÔÓÃÆäËü¿âÀýÈçPIL(Python Imaging Library )£¬Ò»ÖÖÇáÁ¿¼¶µÄͼÏñ¿â¡£Ä¿Ç°openCV1.0°æ±¾¶ÔÓ¦µÄpython°æ±¾Îª2.5£¬openCV2.0¶ÔÓ¦python 2.6¡£
¸½Â¼£º
1. һƪ½éÉÜͼ ......

Python ×Ö·û´®·½·¨


 
Python-String-Function
×Ö·û´®ÖÐ×Ö·û´óСдµÄ±ä»»£º
    * S.lower()   #Сд
    * S.upper()   #´óд
    * S.swapcase()   #´óСд»¥»»
    * S.capitalize()   #Ê××Öĸ´óд
&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ