【问题标题】:'int' object is not callable error in python'int'对象在python中是不可调用的错误
【发布时间】:2013-12-07 17:54:28
【问题描述】:

我收到此错误:

Traceback (most recent call last):
  File "C:\Users\George\Desktop\ex3.py", line 15, in <module>
    s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
TypeError: 'int' object is not callable

这是我的代码:

x=input()
z=input()
n=input()
while x>=z:
    x=input()
    z=input()
while n<0:
    n=input()
while n>0:
    d=(z-x)/1.*n
    k=1
    s=(d/2.)*((-1/6.)*(x-1)*(x-2)*(x+2)*(x-4)+(-1/6.)*(z-1)*(z-2)*(z+2)*(z-4))
    while k<=n-1:
        u=x+k*d
        s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
        k=k+1
        print "%.3f" %s
        x=input()
        z=input()
        n=input()
        if n>0:
            while x>=z:
                x=input()
                z=input()

【问题讨论】:

    标签: python int callable


    【解决方案1】:

    您正在尝试将2 用作函数:

    2(-1/6.)
    

    插入* 进行乘法:

    2*(-1/6.)
    

    或作为一个完整的表达式:

    s=s+d*2*(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
    

    【讨论】:

      猜你喜欢
      • 2020-06-24
      • 2018-08-08
      • 2013-02-07
      • 1970-01-01
      • 2016-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多