rob*_*rob 46 python python-2.7
给出以下整数和计算
from __future__ import division
a = 23
b = 45
c = 16
round((a/b)*0.9*c)
Run Code Online (Sandbox Code Playgroud)
这导致:
TypeError: 'int' object is not callable.
Run Code Online (Sandbox Code Playgroud)
如何将输出舍入为整数?
Dav*_*nan 126
代码中的其他地方你有一些看起来像这样的东西:
round = 42
Run Code Online (Sandbox Code Playgroud)
然后当你写
round((a/b)*0.9*c)
Run Code Online (Sandbox Code Playgroud)
这被解释为对绑定到的对象的函数调用round
,这是一个int
.而那失败了.
问题是无论代码绑定int
到名称round
.找到并删除它.
小智 10
我遇到了同样的错误(TypeError: 'int' object is not callable)
def xlim(i,k,s1,s2):
x=i/(2*k)
xl=x*(1-s2*x-s1*(1-x)) / (1-s2*x**2-2*s1*x(1-x))
return xl
... ... ... ...
>>> xlim(1,100,0,0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in xlim
TypeError: 'int' object is not callable
Run Code Online (Sandbox Code Playgroud)
读完这篇文章后,我意识到我忘记了一个乘号 * 所以
def xlim(i,k,s1,s2):
x=i/(2*k)
xl=x*(1-s2*x-s1*(1-x)) / (1-s2*x**2-2*s1*x * (1-x))
return xl
xlim(1.0,100.0,0.0,0.0)
0.005
Run Code Online (Sandbox Code Playgroud)
坦克
归档时间: |
|
查看次数: |
222870 次 |
最近记录: |