解决numpy模块没有‘np.bool’
•
Python
numpy在1.20版本就弃用了np.bool,需要使用bool或者np.bool_替代。
(以下为个人小实验验证,上面就已经可以解决问题了)
以下是使用了1.20版本的numpy后出现的提示

将1.20版本的numpy从np.bool改为 bool 或者 np.bool_ 如下,就没有包warning

如果使用大于1.20版本的numpy然后使用np.bool


会报错说numpy模块没有bool
![]()
此时也可以直接将代码dtype=np.bool改为使用 dtype=blool 或者 dtype=np.bool_ 即可
dtype=bool
dtype=np.bool_
在Github上也有相关解释
Update `np.bool` to be an alias to `np.bool_` and un-deprecate it · Issue #22021 · numpy/numpy (github.com)
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/f71b008b60.html
