Python报错之TypeError: No loop matching the specified signature and casting was found ...

我先定义一个数组

import numpy as np
arr1=np.array([[1,2,3],[4,5,6],[7,8,9]])

然后我在进行数组运算的时候(代码如下)

arr1/=2

发现出现一个问题

Python报错之TypeError: No loop matching the specified signature and casting was found ..._第1张图片

我的理解是:数组中的元素除以2得到的商会存在数据类型为float的情况,这个时候我尝试去将数组中的元素转化为float类型之后,再运行发现没有报错了。

代码如下:

arr2=arr1.astype(np.float64)
arr2/=2

你可能感兴趣的:(报错问题解决,python,开发语言)