简体   繁体   English

为什么收到此错误“ TypeError:'int'对象不可调用”?

[英]Why do i get this error “TypeError: 'int' object is not callable”?

def diameter(Points):
    '''Given a list of 2d points, returns the pair that's farthest apart.'''
    diam,pair = max([((p[0]-q[0])**2 + (p[1]-q[1])**2, (p,q))
                     for p,q in rotatingCalipers(Points)])
    return pair


n=int(input())

a=[]

max=0

for i in xrange(n):
    m,n=map(int,raw_input().split())
    a.append((m,n))
    diameter(a)

Traceback 追溯

Traceback (most recent call last):
  File "geocheat1.py", line 56, in <module>
    diameter(a)
  File "geocheat1.py", line 43, in diameter
    for p,q in rotatingCalipers(Points)])
TypeError: 'int' object is not callable

From the Traceback it's clear than you are trying to call int object, So rotatingCalipers may be declared as integer in your code. 从回溯它比你想打电话很清楚int对象,所以rotatingCalipers可以声明为在你的代码的整数。

See this example you will understand the error, 查看此示例,您将了解错误,

In [1]: a = (1,2,3)
In [2]: list(a)
Out[1]: [1, 2, 3]
In [3]: list = 5
In [4]: list(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-61edcfee5862> in <module>()
----> 1 list(a)

TypeError: 'int' object is not callable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM