'int'对象在python中不是可调用的错误 [英] 'int' object is not callable error in python

查看:586
本文介绍了'int'对象在python中不是可调用的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

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()


推荐答案

您正在尝试使用 2 作为函数:

You are trying to use 2 as a function:

2(-1/6.)

插入 * 到乘以:

2*(-1/6.)

或作为完整表达式:

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

这篇关于'int'对象在python中不是可调用的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆