实在不知道第11行代码为什么出错,请大家帮帮我.
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)
storage['middle'].setdefault('Lie',[]).append(my_sister)
storage['last'].setdefault('Hetland',[]).append(my_sister)
print(storage)
错误如下:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\storage.py", line 11, in <module>
storage['middle'].setdefault('Lie',[]).append(my_sister)
AttributeError: 'str' object has no attribute 'append'
[此贴子已经被作者于2019-8-17 00:24编辑过]