类型错误:';功能';对象在python中不可下标
我不明白写最后一行有什么问题。 extend1是字典分派中的函数类型错误:';功能';对象在python中不可下标,python,python-3.x,Python,Python 3.x,我不明白写最后一行有什么问题。 extend1是字典分派中的函数 def make_mutable_rlist(ctor=None): """Return a functional implementation of a mutable recursive list""" contents = empty_rlist if ctor != None: i=ctor['length']()-1 print (i) while
def make_mutable_rlist(ctor=None):
"""Return a functional implementation of a mutable recursive list"""
contents = empty_rlist
if ctor != None:
i=ctor['length']()-1
print (i)
while i >=0:
contents = make_rlist(ctor['get_item'](i),contents)
i-=1
def length():
return len_rlist(contents)
def get_item(index):
return getitem_rlist(contents,index)
def push_first(value):
nonlocal contents
contents = make_rlist(value,contents)
def extend1(mutable_list):
nonlocal contents
len1 = length()-1
len2 = mutable_list['length']()
for i in range (len1,len1+len2):
contents['push_first'](mutable_list['get_item'](i))
第二行是什么:
非本地内容
?在extended1@RuhulAmin之外的另一个函数中定义的内容,然后在代码中添加该函数,这样我们就可以检查更新@RuhulAmin内容['push_first'][(可变_列表['get_item'](i))][/code>试试这个