“int”对象在python中不可调用错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20151855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 19:41:03 来源:igfitidea点击:
'int' object is not callable error in python
提问by GeorgeDavidKing
I'm getting this error:
我收到此错误:
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
Here is my code:
这是我的代码:
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()
采纳答案by Martijn Pieters
You are trying to use 2as a function:
您正在尝试2用作函数:
2(-1/6.)
Insert a *to multiply:
插入一个*乘法:
2*(-1/6.)
or as a full expression:
或者作为一个完整的表达:
s=s+d*2*(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)

