構造序列
1._len_(self)
2._getitem_(self,key)
3._setitem_(self,key,value)
4._delitem_(self,key)
程式演示:
myseq.py
class MySeq:
def __init__(self):
self.lseq = ["I","II","III","IV"]
def __len__(self):
return len(self.lseq)
def __getitem__(self,key):
if 0
return self.lseq[key]
if __name__ == "__main__":
m = MySeq()
for i in range(4):
print(m[i])
構造序列
1._len_(self)
2._getitem_(self,key)
3._setitem_(self,key,value)
4._delitem_(self,key)
程式演示:
myseq.py
class MySeq:
def __init__(self):
self.lseq = ["I","II","III","IV"]
def __len__(self):
return len(self.lseq)
def __getitem__(self,key):
if 0
return self.lseq[key]
if __name__ == "__main__":
m = MySeq()
for i in range(4):
print(m[i])