1. what are iterators? an iterator is an object that can be iterated (looped) over. it uses __iter__() to return itself and __next__() to move through elements. example: numbers = [1, 2,...
迭代器是可循环对象,使用__iter__()和__next__()方法。生成器通过yield逐个生成项,节省内存,适合处理大数据。生成器表达式提供简洁语法,类似列表推导,提升代码效率和可扩展性。