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

pythonÁбíºÍ×ÖµäµÄ·½·¨×ܽá

ÁÐ±í·½·¨£º


·½·¨
˵Ã÷
append( item )
ÔÚÁбíĩβ²åÈ루item £©
count( element )
·µ»ØelementÔÚÁбíÖгöÏֵĴÎÊý
extend( newlist )
½«newlistµÄÔªËزåÈëÁбíĩβ
index( element )
·µ»ØelementÔÚÁбíÖеÄË÷Òý£¬Èç¹û²»´æÔÚ£¬ÔòÒý·¢ValueErrorÒì³£
insert( index , item )
ÔÚindexλÖòåÈëitem
pop( [index] )
index²ÎÊýΪ¿ÉÑ¡µÄ¡£ÈçÎ޲ε÷Óã¬Ôò»áɾ³ý²¢·µ»ØÁбí×îºóÒ»¸öÔªËØ¡£ÈçÖ¸¶¨index²Î
Êý£¬Ôòɾ³ý²¢·µ»ØλÖÃindexµÄÔªËØ
remove( element )
ɾ³ýÊ×´ÎÔÚÁбíÖгöÏÖµÄelement£¬Èç¹ûÁÐ±í²»´æÔÚelement£¬ÔòÒý·¢
ValueErrorÒì³£
reverse( )
µ±³¡·´×ªÁбíÄÚÈÝ£¨²»´´½¨·´×ªÁбíµÄ¿½±´£©
sort
µ±³¡¶ÔÁбíÄÚÈÝÅÅÐò¡£¿ÉÑ¡²ÎÊýcompare-functionÊÇÒ»¸öº¯Êý£¬ËüÖ¸¶¨Á˱ȽÏÌõ¼þ

compare-functionÈ¡µÃÁбíµÄÈÎÒâÁ½¸öÔªËØ£¨xºÍy£©¡£Èç¹ûxÓ¦³öÏÖÔÚy֮ǰ£¬
¾Í·¶Î§-1£»Èç¹ûxºÍyµÄ˳ÐòÎ޹ؽôÒª£¬·µ»Ø0£»Èç¹ûxÓ¦³öÏÖÔÚyÖ®ºó£¬Ôò·µ»Ø1
×ÖµäµÄһЩ·½·¨£º
·½·¨
˵Ã÷
clear( )
´Ó×Öµäɾ³ýËùÓÐÏî
copy( )
´´½¨²¢·µ»Ø×ÖµäµÄdz¿½±´£¨ÐÂ×ÖµäÔªËØΪԭʼ×ÖµäµÄÒýÓã©
get(key [ ,returnvalue] )
·µ»ØkeyµÄÖµ£¬ÈôÎÞkey¶øÖ¸¶¨ÁËreturnvalue£¬Ôò·µ»Øreturnvalue
Öµ£¬ÈôÎÞ´ËÖµÔò·µ»ØNone
has_key( key )
Èç¹ûkey´æÔÚÓÚ×ÖµäÖУ¬¾Í·µ»Ø1£¨Õ棩£»·ñÔò·µ»Ø0£¨¼Ù£©
items( )
·µ»ØÒ»¸öÓÉÔª×é¹¹³ÉµÄÁÐ±í£¬Ã¿¸öÔª×é°üº¬Ò»¶Ô¼ü-Öµ¶Ô
keys( )
·µ»ØÒ»¸öÓÉ×ÖµäËùÓмü¹¹³ÉµÄÁбí
popitem( )
ɾ³ýÈÎÒâ¼ü-Öµ¶Ô£¬²¢×÷ΪÁ½¸öÔªËصÄÔª×é·µ»Ø¡£Èç×ÖµäΪ¿Õ£¬Ôò·µ»ØKeyErrorÒì³£
setdefault( key [,dummvalue])
¾ßÓÐÓëget·½·¨ÀàËƵÄÐÐΪ¡£Èçkey²»ÔÚ×ÖµäÖУ¬Í¬Ê±Ö¸¶¨ÁËdummvalue£¬¾Í½«¼ü
£¨key£©ºÍÖ¸¶¨µÄÖµ£¨dummvalue£©²åÈë×ֵ䣬Èç¹ûûÓÐÖ¸¶¨dummvalue£¬ÔòֵΪNone
update( newDictionary )
½«À´×ÔnewDictionaryµÄËùÓмü-ÖµÌí¼Óµ½µ±Ç°×ֵ䣬²¢¸²¸ÇͬÃû¼üµÄÖµ
values( )
·µ»Ø×ÖµäËùÓÐÖµ×é³ÉµÄÒ»¸öÁбí
iterkeys( )
·µ»Ø×Öµä¼üµÄÒ»¸öµü´úÆ÷
iteritems( )
·µ»Ø×Öµä¼ü-Öµ¶ÔµÄÒ»¸öµü´úÆ÷
itervalues( )
·µ»Ø×ÖµäÖµµÄÒ»¸öµü´úÆ÷


Ïà¹ØÎĵµ£º

Python ×Öµä

Python ×Öµä
 
×ÖµäÀàËÆÓÚÄãͨ¹ýÁªÏµÈËÃû×Ö²éÕÒµØÖ·ºÍÁªÏµÈËÏêϸÇé¿öµÄµØÖ·²¾£¬¼´£¬ÎÒÃǰѼü£¨Ãû×Ö£©ºÍÖµ£¨ÏêϸÇé¿ö£©ÁªÏµÔÚÒ»Æð¡£×¢Ò⣬¼ü±ØÐëÊÇΨһµÄ£¬¾ÍÏñÈç¹ûÓÐÁ½¸öÈËÇ¡ÇÉͬÃûµÄ»°£¬ÄãÎÞ·¨ÕÒµ½ÕýÈ·µÄÐÅÏ¢¡£
×¢Ò⣬ÄãÖ»ÄÜʹÓò»¿É±äµÄ¶ÔÏ󣨱ÈÈç×Ö·û´®£©À´×÷Ϊ×ÖµäµÄ¼ü£¬µ«ÊÇÄã¿ÉÒÔ²»¿É±ä»ò¿É±äµÄ¶ÔÏó×÷Ϊ×Öµäµ ......

PythonÖ®¸Ð

´ÓÈ¥Ä껹û±ÏÒµ¾Í½Ó´¥Python£¬ÉÏÖÜÓÐЩÎÞÁÄÖØÐÂÔÙ¿´Ò»±é£¬·¢ÏÖÆäȷʵ²»´í¡£Óï·¨¼òµ¥£¬Ò»¸öÏÂÎç»ù±¾Á˽⣬ʹÓÃPydev²å¼þÔÚEclipseÖнøÐпª·¢»ù±¾ÉÏûÓÐÈκÎÕÏ°­¡£ÖصãÊÇÆäЧÂʺܸߣ¬²»Ðè±àÒëÖ±½ÓÔËÐС£±È½ÏÊʺϽøÐÐÊý¾ÝµÄÔ¤´¦Àí¡£²»´í£¬ÒÔºóÓлú»áºÃºÃÓÃÓᣠ......

pythonѧϰ£¨1£©£­×Öµä (Dictionary)

   
×ֵ䣨Dictionary£©ÊÇÒ»ÖÖÓ³Éä½á¹¹µÄÊý¾ÝÀàÐÍ£¬ÓÉÎÞÐòµÄ“¼ü£­Öµ¶Ô”×é³É¡£×ÖµäµÄ¼ü±ØÐëÊDz»¿É¸Ä±äµÄÀàÐÍ£¬È磺×Ö·û´®£¬Êý×Ö£¬tuple£»Öµ¿É
ÒÔΪÈκÎpythonÊý¾ÝÀàÐÍ¡£
1¡¢Ð½¨×Öµä
>>> dict1={}     
#½¨Á¢Ò»¸ö¿Õ×Öµä
>>> type(dict1)
<ty ......

´î½¨S60ÊÖ»ú¶ËPythonÈí¼þÔËÐÐ,¿ª·¢,·¢²¼Æ½Ì¨

µÚÒ»²½£º´î½¨ÊÖ»úÔËÐÐƽ̨
ÒªÔÚS60ÊÖ»úÉÏÔËÐÐPY¿ª·¢µÄÈí¼þ,Ê×ÏȾÍÒª´î½¨ÊÖ»úPYÔËÐл·¾³.ŵ»ùÑÇÊÖ»ú±¾Éí²»Ö§³ÖPython,ËùÒÔÒª°²×°Python²å¼þ.
PS£ºÒ»¶¨Òª°²×°ÔÚCÅÌ£¡ÎÒÒ»¿ªÊ¼×°E£¬½á¹û³öÏÖÁ˺ÜÑÏÖصÄÎÊÌ⣡²»¹ý,×î½üÍøÉÏ·¢ÏÖÓÐEÅÌ°æµÄÀ²,Äã¿ÉÒÔ×Ô¼ºÊÔÑéһϣ¬¹þ¹þ
PythonScriptShell_1_4_5_3rdEd.SIS
Pyth ......

python Êý×飬ÐòÁУ¬×ֵ䣬ÁÐ±í£¬Ðò±í£¬Ôª×棨tuple£©

python ûÓÐÊý×éµÄÊý¾Ý½á¹¹
#list ÐòÁÐ
sample_list = [1,2,3,'abc']
#dictionary ×Öµä
sample_dic = {"key":value, 2:3}
#tuple Ö»¶ÁµÄÐòÁÐ
sample_tuple = (1,3,"ab")
Ðò±í
    Ðò±íÓÉһϵÁÐÖµÓöººÅ·Ö¸ô¶ø³É
    Ðò±íÓë×Ö·û´®Ò»ÑùÊDz»¿É±äµÄ£º²»ÔÊÐí¶ÔÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ