0
点赞
收藏
分享

微信扫一扫

Python 类函数迭代器


可迭代对象与迭代器

class myIterable(Object):
def __init__(self, mylist):
self.mylist = mylist
def __getitem__(self, index):
return self.mylist[index]

l = myIterable([1, 2, 3])
for i in l:
print(i)

>>> 1
2
3

From:

《深入浅出GAN生成对抗网络》P3.3.2



举报

相关推荐

0 条评论