1. my_dict = { 'Khan': 4, 'Ali': 2, 'Luna': 6, 'Mark': 11, 'Pooja': 8, 'Sara': 1}
    2. print('Original:')
    3. print(my_dict)
    4. my_dict.update({'Khan': 6, 'Luna': 9})
    5. print('\nAfter update:')
    6. print(my_dict)
    1. my_dict = { 'Khan': 4, 'Ali': 2, 'Luna': 6, 'Mark': 11, 'Pooja': 8, 'Sara': 1}
    2. for key, value in my_dict.items():
    3. if key == 'Ali':
    4. my_dict[key] = 10
    5. print(my_dict)
    1. my_dict = { 'Khan': 4, 'Ali': 2, 'Luna': 6, 'Mark': 11, 'Pooja': 8, 'Sara': 1}
    2. my_dict = { **my_dict, 'Pooja': 12}
    3. print(my_dict)

    注:解包方法实际上是创建一个新的字典,而不是更新原来的字典。
    注:推荐用解包方法修改,经测试,其他方法可能失败