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}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/279161.html