TypeError:'numpy.float64'对象不可调用

时间:2021-11-29 21:27:14

So, what im trying to do is get certain numbers from certain positions in a array of a given > range and put them into an equation

因此,我想要做的是从给定>范围的数组中的某些位置获取某些数字并将它们放入等式中

yy = arange(4)
xx = arange(5)
Area = ((xx[2] - xx[1])(yy[2] + yy[1])) / 2

I try to run it and I get this..

我尝试运行它,我得到了..

----> ((xx[2] - xx[1])(yy[2] + yy[1])) / 2
TypeError: 'numpy.int64' object is not callable

I get error.. how can I use certain numbers in an array and put them into an equation?

我得到错误..如何在数组中使用某些数字并将它们放入等式中?

2 个解决方案

#1


11  

Python does not follow the same rules as written math. You must explicitly indicate multiplication.

Python不遵循与书面数学相同的规则。您必须明确指出乘法。

Bad:

(a)(b)

(unless a is a function)

(除非a是函数)

Good:

(a) * (b)

#2


5  

You are missing * when multiplying, try:

在乘法时你缺少*,试试:

import numpy as np
yy = np.arange(4)
xx = np.arange(5)
Area = ((xx[2] - xx[1])*(yy[2] + yy[1])) / 2

#1


11  

Python does not follow the same rules as written math. You must explicitly indicate multiplication.

Python不遵循与书面数学相同的规则。您必须明确指出乘法。

Bad:

(a)(b)

(unless a is a function)

(除非a是函数)

Good:

(a) * (b)

#2


5  

You are missing * when multiplying, try:

在乘法时你缺少*,试试:

import numpy as np
yy = np.arange(4)
xx = np.arange(5)
Area = ((xx[2] - xx[1])*(yy[2] + yy[1])) / 2