擅长:python、mysql、java
<p>来自<code>iter</code>帮助:</p>
<blockquote>
<p>iter(...)<br/>
iter(collection) -> iterator<br/>
iter(callable, sentinel) -> iterator</p>
<pre><code>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.
</code></pre>
</blockquote>
<p>您正在混合<code>iter</code>函数的两个变体。第一个接受集合,第二个接受两个参数-函数和sentinel值。您试图传递collection<strong>和</strong>sentinel值,这是错误的。在</p>
<p>简短说明:您可以从python内置的<code>help</code>函数中获得许多有趣的信息。只需输入python的控制台<code>help(iter)</code>,就可以得到关于它的文档。在</p>
<blockquote>
<p>Why does callabe(list) return true but callable(l) does not? </p>
</blockquote>
<p>因为<code>list</code>是返回新列表对象的函数。函数是可调用的(这是函数所做的-它被调用),而这个函数返回的实例-new list object-不是。在</p>