标签:style blog io color 使用 sp for on div
迭代器使用方法:
#!/usr/bin/env python # !-*-coding:utf-8-*- __author__ = ‘t‘ class anyIter(object): def __init__(self, li): self.li =iter(li) def __iter__(self): return self #重写了 iter 中的next方法. def next(self, howmany=1): retval = None for eachItem in range(howmany): try: retval = self.li.next() except Exception, e: break return retval li = [1, 3, 4, 5, 6, 7, 8, 9] a = anyIter(li) i = iter(a) for s in range(13): print i.next()
标签:style blog io color 使用 sp for on div
原文地址:http://www.cnblogs.com/canbefree/p/4156111.html