这是我写的一些代码:
class supClass:
supList=[]
def __init__(self):
""
class MyClass:
listt=[]
code=None
def __init__(self):
""
instancelist = [ MyClass() for i in range(4)]
for i in range(0,4):
instancelist[i].listt.append(supClass())
instancelist[i].listt.suplist.append(i)
instancelist[i].code=12
for i in range(4):
print instancelist[0].listt.suplist
它产生以下错误:
File "/home/aj/workspace/PythonTutorials/basics/builtFun.py", line 21, in <module>
instancelist[i].listt.suplist.append(i)
AttributeError: 'list' object has no attribute 'suplist'
我该如何解决这个问题?