📜  python 默认字典 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:17.145000             🧑  作者: Mango

代码示例1
from collections import defaultdict

d_int = defaultdict(int)
d_list = defaultdict(list)

def foo():
  return 'default value'
 
d_foo = defaultdict(foo)

>>> d_int
defaultdict(, {})
>>> d_list
defaultdict(, {})
>>> d_foo
defaultdict(, {})