类型错误:“浮动"对象不可调用 [英] TypeError: 'float' object is not callable

查看:25
本文介绍了类型错误:“浮动"对象不可调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在以下等式中使用数组中的值:

I am trying to use values from an array in the following equation:

for x in range(len(prof)):
    PB = 2.25 * (1 - math.pow(math.e, (-3.7(prof[x])/2.25))) * (math.e, (0/2.25)))

运行时出现以下错误:

Traceback (most recent call last):
  File "C:/Users/cwpapine/Desktop/1mPro_Chlavg", line 240, in <module>
    PB = float(2.25 * (1 - math.pow(math.e, (-3.7(prof[x])/2.25))) * (math.e, (0/2.25)))
TypeError: 'float' object is not callable

这可能很简单,但我不太明白.任何帮助都会非常感激.提前致谢

this is probably something simple but I can't quite figure it out. Any help would be greatly appreciated. Thanks in advance

推荐答案

缺少一个运算符,可能是 *:

There is an operator missing, likely a *:

-3.7 need_something_here (prof[x])

is not callable"发生是因为括号——以及缺少将括号切换为优先运算符的运算符——使 Python 尝试调用-3.7(浮点数)作为函数的结果,这是不允许的.

The "is not callable" occurs because the parenthesis -- and lack of operator which would have switched the parenthesis into precedence operators -- make Python try to call the result of -3.7 (a float) as a function, which is not allowed.

在这种情况下也不需要括号,以下内容可能足够/正确:

The parenthesis are also not needed in this case, the following may be sufficient/correct:

-3.7 * prof[x]

<小时>

正如 Legolas 指出的那样,还有其他事情可能需要解决:


As Legolas points out, there are other things which may need to be addressed:

2.25 * (1 - math.pow(math.e, (-3.7(prof[x])/2.25))) * (math.e, (0/2.25)))
                                  ^-- op missing
                                                    extra parenthesis --^
               valid but questionable float*tuple --^
                                     expression yields 0.0 always --^

这篇关于类型错误:“浮动"对象不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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