1、凡是可作用于for循环的对象都是Iterable类型;
for
Iterable
2、凡是可作用于next()函数的对象都是Iterator类型,它们表示一个惰性计算的序列;
next()
Iterator
3、集合数据类型如list、dict、str等是Iterable但不是Iterator,不过可以通过iter()函数获得一个Iterator对象。
list
dict
str
iter()
4、Python的for循环本质上就是通过不断调用next()函数实现的,例如: