dict.setdefault使用说明

a={}
result=a.setdefault("e")#return None and a add a new key-value pair
print a
#a={"e":None}
result-a.setdefault("e","eeee")#return None,because the dict already has "e" element so it return current "e"'s value,

你可能感兴趣的:(set)