gpt4 book ai didi

python - 'int' object is not callable 错误在 python 中

转载 作者:太空狗 更新时间:2023-10-29 21:15:30 24 4
gpt4 key购买 nike

我收到这个错误:

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 用作函数:

2(-1/6.)

插入一个*来相乘:

2*(-1/6.)

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

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

关于python - 'int' object is not callable 错误在 python 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20151855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com