NULL
博文链接:https://shixm.iteye.com/blog/381884abstract
Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple
but effective approach to ohject-oriented programming. Python's elegant syntax a
本文实例为大家分享了python使用生成器实现可迭代对象的具体代码,供大家参考,具体内容如下
案例分析:
实一个可迭代对象的类,它能迭代出给定范围内所有的素数:
pn = Number(1, 30)
for k in pn:
print(k)
结果为:2,3,5,7,11,13,17,19,23,29
如何解决这个问题?
将该类的__iter__方法实现成