擅长:python、mysql、java
<p>当您试图用<strong><code>()</code></strong>调用一个不是<a href="http://docs.python.org/2/reference/datamodel.html#object.__call__" rel="noreferrer">callable</a>的对象时,就会发生此错误。</p>
<p>可调用对象可以是函数或类(实现<code>__call__</code>方法)。根据<a href="http://docs.python.org/2/reference/datamodel.html#object.__call__" rel="noreferrer">Python Docs</a>:</p>
<blockquote>
<p><strong>object.__call__(self[, args...])</strong>: Called when the instance is “called” as a function</p>
</blockquote>
<p>例如:</p>
<pre><code>x = 1
print x()
</code></pre>
<p><code>x</code>不是可调用的对象,但您正试图将其作为可调用对象来调用。此示例生成错误:</p>
<pre><code>TypeError: 'int' object is not callable
</code></pre>
<hr/>
<p>为了更好地理解什么是可调用的对象<a href="https://stackoverflow.com/a/111255/2670792">read this answer in another SO post.</a></p>