【问题标题】:int object not callable error in python [closed]python中的int对象不可调用错误[关闭]
【发布时间】:2013-02-07 12:55:39
【问题描述】:

下面这段代码给了我错误

fd=((1/(sd*sqrt(6.28)))*2.718**((-1(d-average)**2))/(2*sd**2)))

这是错误

Traceback (most recent call last):
  File "C:\Users\etc
    fd=((1/(sd*sqrt(6.28)))*2.718**((-1(d-average)**2))/(2*sd**2))
TypeError: 'int' object is not callable

我找不到 int 对象“不可调用”的位置

谢谢

【问题讨论】:

  • 那是因为表达方式很丑。使用一堆临时变量。 (我的猜测是您在括号之前缺少-1(d-average) 的运算符。)
  • 您的示例代码和错误消息的代码不同。
  • 我有这个想法,但我的教授希望看到他给我们的代码中的确切方程式。还是谢谢
  • 是的,但是会弹出同样的错误,无法修复

标签: python object int typeerror


【解决方案1】:

您在 -1 之后缺少 * 运算符。

【讨论】:

  • 哦,好的,我现在明白了.. 谢谢!
  • 为了将来参考,错误信息很有帮助。 'int' object is not callable 告诉您您正在尝试执行 () 之类的操作。我只是在寻找一个 int 与 parens 对接的地方。
【解决方案2】:

这是由 Python 尝试像这样“调用”的 int 对象造成的:

>>> 2*(1+3)
8
>>> 2(1+3)        #note missing *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable

【讨论】:

    猜你喜欢
    • 2017-04-15
    • 1970-01-01
    • 2020-06-24
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 1970-01-01
    • 2020-06-27
    相关资源
    最近更新 更多