0

字典结构为:

storage = {}   
storage['first'] = {}   
storage['middle'] = {}  
storage['last'] = {}

对该字典的第一个插入是:

me = 'Magnus Lie Hetland'   
storage['first']['Magnus'] = [me]  
storage['middle']['Lie'] = [me] 
storage['last']['Hetland'] = [me]

然后执行以下语句:

my_sister = 'Anne Lie Hetland'
storage['first'].setdefault('Anne', []).append(my_sister)

根据文档setdefault应该插入'Anne'带有值的键[] (New Empty list),然后它应该附加my_sister. 那么为什么它附加my_sister到预先存在的列表而不是创建新列表。

4

0 回答 0