#!python # encoding: utf-8 import collections def default_factory(): return 'default value' d=collections.defaultdict(default_factory,foo='bar',ok='ok') print 'd:',d print 'foo=>',d['foo'] print 'ok=>',d['ok'] print 'bar=>',d['bar']
本文转自黄聪博客园博客,原文链接:http://www.cnblogs.com/huangcong/archive/2012/12/13/2815606.html,如需转载请自行联系原作者