Py学习  »  William Bright  »  全部回复
回复总数  1
5 年前
回复了 William Bright 创建的主题 » 如果没有正常函数的sentinel值,Python iter函数将无法工作
Docstring:
iter(iterable) -> iterator
iter(callable, sentinel) -> iterator

Get an iterator from an object.  In the first form, the argument must
supply its own iterator, or be a sequence.
In the second form, the callable is called until it returns the sentinel.

所以你选择了第二种形式,这意味着它将永远循环,直到哨兵在这种情况下 '' 被退回。