Is it possible to add a key to a Python dictionary after it has been created?
(创建密钥后,是否可以向Python字典添加密钥?)
.add()
(它似乎没有.add()方法。)
d = {'key':'value'} print(d) # {'key': 'value'} d['mynewkey'] = 'mynewvalue' print(d) # {'mynewkey': 'mynewvalue', 'key': 'value'}
2.1m questions
2.1m answers
60 comments
57.0k users