-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