锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲日韩国产一区二区三区在线,日韩在线视精品在亚洲,小说专区亚洲春色校园http://www.tkk7.com/JafeLee/category/25249.htmlzh-cnWed, 29 Aug 2007 04:30:25 GMTWed, 29 Aug 2007 04:30:25 GMT60Chapter 3 Native Datatypes -- tuplehttp://www.tkk7.com/JafeLee/archive/2007/08/28/140660.htmlJafeJafeTue, 28 Aug 2007 13:11:00 GMThttp://www.tkk7.com/JafeLee/archive/2007/08/28/140660.htmlhttp://www.tkk7.com/JafeLee/comments/140660.htmlhttp://www.tkk7.com/JafeLee/archive/2007/08/28/140660.html#Feedback0http://www.tkk7.com/JafeLee/comments/commentRss/140660.htmlhttp://www.tkk7.com/JafeLee/services/trackbacks/140660.html Example 3.15 Defining a tuple Chapter 3 Native Datatypes -- listhttp://www.tkk7.com/JafeLee/archive/2007/08/27/140131.htmlJafeJafeMon, 27 Aug 2007 13:11:00 GMThttp://www.tkk7.com/JafeLee/archive/2007/08/27/140131.htmlhttp://www.tkk7.com/JafeLee/comments/140131.htmlhttp://www.tkk7.com/JafeLee/archive/2007/08/27/140131.html#Feedback0http://www.tkk7.com/JafeLee/comments/commentRss/140131.htmlhttp://www.tkk7.com/JafeLee/services/trackbacks/140131.html Example 3.6 Defining a List 1銆乴ist鐨勫厓绱犳槸鏈夊簭鐨?br />2銆乴ist鍙互褰撴垚鏁扮粍鏉ョ敤錛屽厓绱犱笅鏍囦粠0寮濮?br />
Example 3.7 Negative List Indices
3銆乴ist鐨勭儲寮曞彲浠ユ槸璐熸暟錛岃〃杈懼紡L[n]鐨勫惈涔変負錛?br />錛?錛夊綋0 <= n <= len(L)-1 鏃訛紝 璺焜ava銆丆涓殑鏁扮粍鍏冪礌绱㈠紩涓鏍?br />錛?錛夊綋-len(L) <= n <= -1 鏃? L[n] = L[len(L)+n]
錛?錛塶涓嶅啀涓婅堪鑼冨洿鍐呮槸錛岀▼搴忓紩鍙慖ndexError
Slicing a list
榪愯緇撴灉錛?br />
榪愯緇撴灉
4銆丩[a:b]錛堝叾涓璦,b涓烘暣鏁幫級琛ㄧず涓涓垎鐗囨搷浣滐紝娉ㄦ剰a錛宐鍙互鏄換鎰忕殑鏁存暟錛岃屼笖鍒嗙墖鎿嶄綔姘歌繙涓嶄細寮曞彂IndexError銆備絾鏄痑錛宐鍙栦笉鍚岀殑鍊兼椂錛岀▼搴忚涓虹◢鏈変笉鍚屻?br />錛?錛夊綋 0 <= a < b < len(L)鏃訛紝L[a:b]榪斿洖涓涓敱L[a], L[a+1]...L[b-1]緇勬垚鐨刲ist
錛?錛夊綋 0 <= b <= a < len(L)鏃訛紝L[a:b]榪斿洖絀虹殑list
錛?錛夊綋a錛宐鍙栧間笉鍦ㄤ笂榪拌寖鍥存椂錛屽簲鐢ㄤ互涓?鏉¤鍒欐浛鎹錛宐鐨勫鹼紝寰楀埌a錛宐鏂扮殑鍊煎悗鍐嶅簲鐢ㄤ笂闈袱鏉¤鍒欍?br />
  • 鑻?a >= len(L), 鍒?a = len(L)-1
  • 鑻?-len(L) <= a < 0, 鍒?a = len(L) + a
  • 鑻?a <聽 -len(L)錛?鍒櫬?a =聽 0
  • b鐨勬儏鍐佃窡a涓鏍?
  • 褰?a娌℃湁鎸囧畾鏃訛紝a = 0, 褰揵娌℃寚瀹氭椂錛宐=len(L)-1
5銆乤ppend鍜宔xtend鏂規硶鐨勪笉鍚岋紝鐪嬩笅渚嬪氨涓鐩簡鐒朵簡銆?br />
the difference between extend and append
娉ㄦ剰 extend鐨勫弬鏁頒笉浠呬粎鍙互鏄痩ist錛屼篃鍙互鏄竴涓猼uple, dictionary絳夊彲浠terable鐨勬暟鎹粨鏋?br />6銆?

List object methods

Method

Description

Nonmutating methods

L.count(x)

Returns the number of items of L that are equal to x.

L.index(x)

Returns the index of the first occurrence of an item in L that is equal to x, or raises an exception if L has no such item.

Mutating methods

L.append(x)

Appends item x to the end of L ; e.g., L[len(L):]=[x].

L.extend(s)

Appends all the items of iterable s to the end of L; e.g., L[len(L):]=s.

L.insert(i, x)

Inserts item x in L before the item at index i, moving following items of L (if any) "rightward" to make space (increases len(L) by one, does not replace any item, does not raise exceptions: acts just like L[i:i]=[x]).

L.remove(x)

Removes from L the first occurrence of an item in L that is equal to x, or raises an exception if L has no such item.

L.pop([i])

Returns the value of the item at index i and removes it from L; if i is omitted, removes and returns the last item; raises an exception if L is empty or i is an invalid index in L.

L.reverse( )

Reverses, in place, the items of L.

L.sort([f]) (2.3)

Sorts, in place, the items of L, comparing items pairwise via function f; if f is omitted, comparison is via the built-in function cmp. For more details, see "Sorting a list" on page 57.

L.sort(cmp=cmp, key=None, reverse=False)(2.4)

Sorts, in-place, the items of L, comparing items pairwise via the function passed as cmp (by default, the built-in function cmp). When argument key is not None, what gets compared for each item x is key(x), not x itself. For more details, see "Sorting a list" on page 57.

7銆?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">List Operators娉ㄦ剰涓嬮潰鐨勪緥瀛愶細
Another Example
榪愯緇撴灉錛?br />
榪愯緇撴灉



Jafe 2007-08-27 21:11 鍙戣〃璇勮
]]>
chapter 3: Native Datatypes -- dictionaryhttp://www.tkk7.com/JafeLee/archive/2007/08/26/139420.htmlJafeJafeSun, 26 Aug 2007 03:31:00 GMThttp://www.tkk7.com/JafeLee/archive/2007/08/26/139420.htmlhttp://www.tkk7.com/JafeLee/comments/139420.htmlhttp://www.tkk7.com/JafeLee/archive/2007/08/26/139420.html#Feedback0http://www.tkk7.com/JafeLee/comments/commentRss/139420.htmlhttp://www.tkk7.com/JafeLee/services/trackbacks/139420.html Example 3.1 Defining a Dictionary 1銆佹瘡涓涓猟ictionary涓殑姣忎竴涓猧tem灝辨槸涓瀵瑰鹼細key-value銆傚彲浠ラ氳繃key寮曠敤value錛屼絾涓嶈兘閫氳繃value寮曠敤key銆?br />2銆佹瘡涓涓猭ey鏄ぇ灝忓啓鏁忔劅鐨?br />3銆佺粰涓涓猟ictionary娣誨姞涓涓柊item錛歞ictName[newKey] = newValue銆傚鏋渘ewKey瀛樺湪錛屽垯newValue浼氳鐩栧師鏉ョ殑value銆傝繖涔熻〃鏄庢坊鍔犮佷慨鏀筰tem鐢ㄧ殑鏄浉鍚岀殑璇硶銆?br />4銆乿alue鐨勭被鍨嬪彲浠ユ槸浠繪剰鐨勶紝鍚屼竴涓猟ictionary涓殑value鐨勭被鍨嬪茍涓嶉渶瑕佷竴鑷淬俴ey鐨勭被鍨嬪繀欏繪槸鎵鏈変笉鍙彉鐨勭被鍨嬶紝tuple鏈夋椂涔熷彲浠ヤ綔涓簁ey錛岃繖鏃跺檛uple涓嶈兘鍖呭惈鍙彉綾誨瀷錛屼笉綆℃槸鐩存帴鍖呭惈榪樻槸闂存帴鍖呭惈銆?br />5銆乨el D[k]鍒犻櫎涓涓猭ey鏄痥鐨刬tem銆?br />6銆佹搷浣?k in D 鍙互鐢ㄦ潵媯鏌?font color="#ff0000">key k 鏄惁鍖呭惈鍦―鐨勬墍鏈塳eys涓?br />7
Dictionary object methods

Method

Description

Nonmutating methods

D.copy( )

Returns a shallow copy of the dictionary (a copy whose items are the same objects as D's, not copies thereof)

D.has_key(k)

Returns TRue if k is a key in D; otherwise, returns False, just like kinD

D.items( )

Returns a new list with all items (key/value pairs) in D

D.keys( )

Returns a new list with all keys in D

D.values( )

Returns a new list with all values in D

D.iteritems( )

Returns an iterator on all items (key/value pairs) in D

D.iterkeys( )

Returns an iterator on all keys in D

D.itervalues( )

Returns an iterator on all values in D

D.get(k[,x])

Returns D[k] if k is a key in D; otherwise, returns x (or None, if x is not given)

Mutating methods

D.clear( )

Removes all items from D, leaving D empty

D.update(D1)

For each k in D1, sets D[k] equal to D1[k]

D.setdefault(k[,x])

Returns D[k] if k is a key in D; otherwise, sets D[k] equal to x and returns x

D.pop(k[,x])

Removes and returns D[k] if k is a key in D; otherwise, returns x (or raises an exception if x is not given)

D.popitem( )

Removes and returns an arbitrary item (key/value pair)





Jafe 2007-08-26 11:31 鍙戣〃璇勮
]]>
Chapter 2 Your First Python Programhttp://www.tkk7.com/JafeLee/archive/2007/08/25/139333.htmlJafeJafeSat, 25 Aug 2007 14:46:00 GMThttp://www.tkk7.com/JafeLee/archive/2007/08/25/139333.htmlhttp://www.tkk7.com/JafeLee/comments/139333.htmlhttp://www.tkk7.com/JafeLee/archive/2007/08/25/139333.html#Feedback0http://www.tkk7.com/JafeLee/comments/commentRss/139333.htmlhttp://www.tkk7.com/JafeLee/services/trackbacks/139333.html Example 2.1 odbchelper.py 1銆佸嚱鏁幫紙function)瀹氫箟鏃犻渶鎸囧畾榪斿洖綾誨瀷銆備簨瀹炰笂錛屾墍鏈塸ython鍑芥暟閮戒細榪斿洖涓涓箋傚綋浣犵殑鍑芥暟瀹氫箟娌℃湁return璇彞鏃訛紝鍑芥暟灝嗚繑鍥濶one銆傚涓嚱鏁板弬鏁?function argument)鐢ㄩ楀彿闅斿紑銆傦紙榪欓噷鏈変竴涓枒闂紝涓轟粈涔堟槸function argument鑰屼笉鏄痜unction parameter鍛紵@@錛?br />2銆丳ython鏄竴涓姩鎬佺殑銆?b>寮虹被鍨?/font>鐨勮璦錛坉ynamically聽 & strongly type language)
3銆佹敞閲婂嚱鏁幫細錛坉ocumenting function)浠?""寮濮嬶紝浠?""緇撴潫錛屽彲浠ラ氳繃鍐呭緩灞炴?__doc__ 鑾峰緱銆傝屼笖娉ㄩ噴蹇呴』鍦ㄥ嚱鏁版渶寮濮嬮儴鍒嗗厛瀹氫箟錛屽惁鍒欒皟鐢╛_doc__鏃朵綘灝嗗緱鍒癗one.
4銆丒verything is a object!
5銆乮f __name__ == "__main__":
榪欐槸鍦ㄦ祴璇曟ā鍧椼傚湪涓婁緥涓綋妯″潡鐙珛榪愯鏃訛紝妯″潡鐨勫唴寤哄睘鎬?__name__ == "__main__"錛屽綋妯″潡琚玦mport鏃訛紝__name__ == "odbchelper"



Jafe 2007-08-25 22:46 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲熟妇av一区二区三区下载| 亚洲天堂免费在线视频| 777亚洲精品乱码久久久久久 | 中国黄色免费网站| 亚洲成a人片在线播放| 看全免费的一级毛片| 免费看男女下面日出水视频| 污污免费在线观看| 国产亚洲精品a在线观看| 久久久久久国产a免费观看不卡| 亚洲一级Av无码毛片久久精品| 黄色短视频免费看| 国产亚洲一区二区三区在线| 全免费a级毛片免费看| 亚洲人成电影福利在线播放 | 国产精品手机在线亚洲| 亚洲高清成人一区二区三区| 亚洲精品视频免费观看| 亚洲AV中文无码字幕色三| 最近新韩国日本免费观看| 亚洲香蕉久久一区二区| 国产一区二区三区在线免费观看| 国产偷国产偷亚洲高清在线| 亚洲自偷自偷在线制服| 91九色视频无限观看免费| 亚洲日本一线产区和二线| 亚洲第一成人影院| 99爱在线精品视频免费观看9| 亚洲AV无码久久久久网站蜜桃 | 天天摸天天操免费播放小视频| 美女啪啪网站又黄又免费| 精品亚洲综合久久中文字幕| 中文字幕免费在线看线人 | 人妻免费一区二区三区最新| 久久亚洲AV成人无码软件| 免费无码又爽又刺激高潮| 亚欧乱色国产精品免费视频| 亚洲色图.com| 亚洲精品国产精品乱码不卡 | 99久久免费看国产精品| 亚洲av无码无线在线观看|