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
Ïà¹ØÎĵµ£º
½ñÌìÓÖɨÁËÒ»±éÊý×ÖÕâÒ»ÕÂ.. ¿´µ½ÁËround()º¯Êý, ÊÇÔÚpythonºËÐıà³Ì˼ÏëµÄ5.6.2½ÚµÄĩβ, ÔÎÄÈçÏÂ:
round(flt, ndig=0) ½ÓÊÜÒ»¸ö¸¡µãÊý flt ²¢¶ÔÆäËÄÉáÎåÈ룬±£´æ ndigλСÊý¡£
Èô²»Ìṩndig ²ÎÊý£¬ÔòĬÈÏСÊýµãºó0λ¡£
round()½öÓÃÓÚ¸¡µãÊý¡££¨ÒëÕß×¢£ºÕûÊýÒ²¿ÉÒÔ£¬ ²»¹ý²¢Ã»ÓÐʲô
ʵ¼ÊÒâÒ壩
Æäʵ, ×ö¸ö浄 ......
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 ......
ĿǰΪֹ£¬¾ÝÎÒËùÖª£¬ÔÚpythonÖжÔÏó³Ö¾Ã»¯ÓÐÒÔϼ¸ÖÖ·½·¨£º
1. ʹÓÃ(dbhash/bsddb, dbm, gdbm, dumbdbm µÈ£©ÒÔ¼°ËüÃǵÄ"¹ÜÀíÆ÷"( anydbm )¡£Ö»ÌṩÁË Python ×Ö
·û´®µÄÓÀ¾ÃÐÔ´¢´æ. Ìṩһ¸öÀàËÆ×ÖµäºÍÎļþµÄ¶ÔÏ󣬿ÉÒÔÍê³É×Ö·û´®µÄÓÀ¾ÃÐÔ´æ´¢¡£
2. ʹÓÃmarshalºÍpickleÀ´ÐòÁл¯python¶ÔÏ󣬲¢¾ß±¸´æ´¢µ½½éÖÊÉϵĹ ......
ÓÉsubprocess´´½¨Ò»¸ö½ø³Ì£¬È»ºó½øÐмàÊÓ
ÿһÃëÖӲ鿴һ´Î£¬Èç¹ûÕýÔÚÔËÐУ¬´òÓ¡pidºÍrunning£¬Èç¹ûÒÑÍ£Ö¹£¬,¼ÌÐøÖ´ÐÐÈÎÎñ²¢´òÓ¡Termined
shellºÍstdout¾ùÉèÖÃΪFalse
Ò²ÐíÕâ¶Ô×ö²¡¶¾µÄÊØ»¤½ø³ÌºÜºÃ
#!/usr/bin/env python
import subprocess , sys , time
p=subprocess.Popen(['ping','127.0.0.1','-n','10'], she ......
http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-pydev/Á¬½ÓÕâ¸öÍøÖ·£¬²»»áÈÃÄãʧÍûµÄ¡£
PyDev ¼ò½é
2003Äê7ÔÂ16ÈÕ£¬ÒÔ Fabio Zadrozny ΪÊ×µÄÈýÈË¿ª·¢Ð¡×éÔÚÈ«Çò×î´óµÄ¿ª·ÅÔ´´úÂëÈí¼þ¿ª·¢Æ½Ì¨ºÍ²Ö¿â SourceForge ÉÏ×¢²áÁËÒ»¿îеÄÏîÄ¿£¬¸ÃÏîĿʵÏÖÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄ Eclipse²å¼þ£¬Óû§¿ÉÒÔÍêÈ«ÀûÓà Eclipse À ......