方法 | 描述 |
---|---|
dict.update([other]) | 將 dict 以 other 更新 |
舉例示範如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | d1 = { "a" : 1 , "b" : 2 , "c" : 3 } print (d1) d1.update() print (d1) print () d2 = { "d" : 4 , "e" : 5 , "f" : 6 } print (d2) d2.update({ "1" : 1 , "2" : 2 , "4" : 4 , "5" : 5 }) print (d2) print () d3 = { "g" : 7 , "h" : 8 , "i" : 9 } print (d3) d3.update(g = 1 , h = 0 ) print (d3) print () # 《程式語言教學誌》的範例程式 # 檔名:update.py # 功能:示範 Python 程式 # 作者:張凱慶 # 時間:西元 2010 年 12 月 |
執行結果如下

中英文術語對照 | |
---|---|
字典 | dictionary |
型態 | type |
方法 | method |
沒有留言:
張貼留言