这里我定义了一个正常函数:
def abc():
return 1
for i in iter(abc):
print i
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'function' object is not iterable
但现在当我用哨兵的时候,它起作用了。
for i in iter(abc, ''):
print i
1
1
1
1
1
1
...
你知道为什么会发生上述行为吗?