标签:
1.RandSeq
#coding:utf-8 #!/usr/bin/env python ‘randSeq.py -- 迭代‘ #从random模块里仅仅导入choice方法 from random import choice class RandSeq(object): def __init__(self,seq): self.data = seq; def __iter__(self): return self; def next(self): return choice(self.data) if __name__ == ‘__main__‘: for eachItem in RandSeq((‘rock‘,‘paper‘,‘scisc‘)): print eachItem
Python学习笔记——迭代器(RandSeq和AnyIter)
标签:
原文地址:http://www.cnblogs.com/tonglin0325/p/5911177.html