📅  最后修改于: 2022-03-11 14:45:07.425000             🧑  作者: Mango
>>> from collections import defaultdict
>>> d = {'foo': 123, 'bar': 456}
>>> d['baz']
Traceback (most recent call last):
File "", line 1, in
KeyError: 'baz'
>>> d = defaultdict(lambda: -1, d)
>>> d['baz']
-1