# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法setdefault() #D.get(k,d)
#说明:k在D中,则返回 D[K],如果k不在D中,则返回d值
#D.get(k,d), also set D[k]=d if k not in D
'''
>>> help(dict.setdefault)
Help on built-in function setdefault: setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
''' #案例
D={'name':'xiaodeng','age':28}
print D.setdefault('name') #xiaodeng
print D.setdefault('color','yellow') #yellow为默认值