立即学习:https://edu.csdn.net/course/play/26676/399743?utm_source=blogtoedu
具有"__iter__"这个方法的对象为可迭代对象
hasattr(list,"__iter__") 验证list列表是否为可迭代对象,返回值为True,则是可迭代对象。
迭代器对象
__next__
生成器对象
yield
(x**2 for x in range(10))生成器解析,不是元组解析
立即学习:https://edu.csdn.net/course/play/26676/399743?utm_source=blogtoedu
具有"__iter__"这个方法的对象为可迭代对象
hasattr(list,"__iter__") 验证list列表是否为可迭代对象,返回值为True,则是可迭代对象。
迭代器对象
__next__
生成器对象
yield
(x**2 for x in range(10))生成器解析,不是元组解析