锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲日韩国产一区二区三区在线,日韩在线视精品在亚洲,小说专区亚洲春色校园http://m.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://m.tkk7.com/JafeLee/archive/2007/08/28/140660.htmlJafeJafeTue, 28 Aug 2007 13:11:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/08/28/140660.htmlhttp://m.tkk7.com/JafeLee/comments/140660.htmlhttp://m.tkk7.com/JafeLee/archive/2007/08/28/140660.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/140660.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/140660.html Example 3.15 Defining a tuple Chapter 3 Native Datatypes -- listhttp://m.tkk7.com/JafeLee/archive/2007/08/27/140131.htmlJafeJafeMon, 27 Aug 2007 13:11:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/08/27/140131.htmlhttp://m.tkk7.com/JafeLee/comments/140131.htmlhttp://m.tkk7.com/JafeLee/archive/2007/08/27/140131.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/140131.htmlhttp://m.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://m.tkk7.com/JafeLee/archive/2007/08/26/139420.htmlJafeJafeSun, 26 Aug 2007 03:31:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/08/26/139420.htmlhttp://m.tkk7.com/JafeLee/comments/139420.htmlhttp://m.tkk7.com/JafeLee/archive/2007/08/26/139420.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/139420.htmlhttp://m.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://m.tkk7.com/JafeLee/archive/2007/08/25/139333.htmlJafeJafeSat, 25 Aug 2007 14:46:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/08/25/139333.htmlhttp://m.tkk7.com/JafeLee/comments/139333.htmlhttp://m.tkk7.com/JafeLee/archive/2007/08/25/139333.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/139333.htmlhttp://m.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 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲一区免费视频| 午夜影院免费观看| 免费一级毛片一级毛片aa| 2020天堂在线亚洲精品专区| 51在线视频免费观看视频| 亚洲综合精品香蕉久久网97| 69视频在线是免费观看| 亚洲黄色免费观看| 成年黄网站色大免费全看| 亚洲一区二区三区亚瑟| 国产又黄又爽又猛免费app| 天天爽亚洲中文字幕| 麻豆国产入口在线观看免费| 国产成人精品久久亚洲高清不卡| 国产大片线上免费看| 女人裸身j部免费视频无遮挡| 亚洲人成网站18禁止一区| 一级女人18片毛片免费视频| 亚洲热妇无码AV在线播放| 在线看片免费人成视频福利| 亚洲第一成年人网站| 毛片a级毛片免费观看品善网| 亚洲精品无码久久| 亚洲色偷偷综合亚洲AV伊人| A国产一区二区免费入口| 久久精品国产亚洲av麻豆色欲| 免费不卡视频一卡二卡| 日韩在线视精品在亚洲| 亚洲中文字幕无码不卡电影| 69视频在线是免费观看| 亚洲精品久久久久无码AV片软件| 亚洲精品乱码久久久久久不卡| 久久久久国产免费| 亚洲国产精品久久久久秋霞小| 亚洲一区精品伊人久久伊人| 久久久久高潮毛片免费全部播放 | 中文字幕亚洲综合久久综合| 国产成人免费网站在线观看| 免费人成在线观看视频高潮| 亚洲依依成人亚洲社区| 亚洲精品一品区二品区三品区|