-2
新的Python的操控列表,但经验丰富的在旧的语言:类对象实例
class a_cell:
'Basic class structure of a cell'
def __init__(self):
self.number = 0
self.row = 1
self.column = 1
self.kind = "variable"
self.value = 4
# -- cell_ is list of a_cell class objects --
for i in range (1,100):
cell_ =[a_cell()] # for i in range (1,100)]
print("cell_",str(i), cell_[i-1].kind)
# do I need both of the "for i in range..." creatipm loops
**错误列表索引超出范围,最后一排,我如何访问我的对象的属性?
啊,谢谢。肯定表明我不知道Python或其方法。 – Mace
如何访问,比如cell_ object索引号15,属性'kind'? – Mace
您可以使用cell_ [index_number] .kind进行访问 – bekirzahid