python 迭代器

from collections import Iterator

class IterA(Iterator):

def __init__(self,Itlist):

self.Itlist = Itlist
self.index = 0

def next(self):
if self.index == len(self.Itlist):
raise StopIteration
a = self.Itlist[self.index]

self.index +=1
return a
posted @ 2018-07-05 20:59  破晓e  阅读(73)  评论(0编辑  收藏  举报