有一行代码c = np.fromfile("b.dat", dtype=np.int, sep=",") 运行时报错,内容如下:
DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
c = np.fromfile("b.dat", dtype=np.int, sep=",")
原因:numpy1.20开始已经将np.int废弃了,check了一下自己的版本,果然
numpy版本已经到1.23.2
解决办法:改成np.int16/np.int32 直接指定到具体的字节 或者改为np.int_
再次运行,问题解决!