001、
>>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict1['e'] = 500 ## 添加元素e >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400, 'e': 500}
002、
>>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict1.update(e = 500) ## update添加元素e >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400, 'e': 500}