function call questions
chenyong20000 at gmail.com
chenyong20000 at gmail.com
Wed Oct 19 02:30:02 EDT 2016
在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道:
> On 2016-10-19 03:15, chenyong20000 at gmail.com wrote:
> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first question. But the second question still confused me. Why "it seems that
> > after root = root.setdefault(ch,{}) tree['a'] and root are the same
> > object" and follows tree['a']['b']? Thanks.
> >
> You call the .setdefault method with a key and a default value.
>
> The .setdefault method does this: if the key is in the dict, it returns
> the associated value, else it puts the key and the default into the dict
> and then returns the default.
thanks for the reply. I understand this. I'm now confused on why tree got its magic result.
More information about the Python-list
mailing list