update နည်းလမ်း
update နည်းလမ်းသည် မူလ
dictionary ကို အခြား dictionary ၏ key
များနှင့် value များဖြင့် ဖြည့်စွက်ပေးပါသည်။
နည်းလမ်း၏ parameter တွင် မူလ dictionary ကို
ဖြည့်စွက်မည့် dictionary ကို သတ်မှတ်ပေးရပါမည်။
Syntax
dictionary.update(မူလ dictionary ကို ဖြည့်စွက်မည့် dictionary)
ဥပမာ
update နည်းလမ်းကို အသုံးပြု၍ ကျွန်ုပ်တို့၏
dictionary ကို အပ်ဒိတ်လုပ်ကြည့်ရအောင်။
dct1 = {
'a': 1,
'b': 2,
'c': 3
}
dct2 = {
'e': 4,
'f': 5
}
dct1.update(dct2)
print(dct1)
ကုဒ်ကို run လိုက်သည့်အခါ ရရှိမည့် ရလဒ်။
{'a': 1, 'b': 2, 'c': 3, 'e': 4, 'f': 5}