a=np.array([1,2,3],dtype=np.int)
print(a)
这样输出的结果中,会出现:
C:\Users\16079\untitled0.py:16: 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
a=np.array([1,2,3],dtype=np.int)
这样会使结果隐藏而不利于输出结果的查找。
将代码该为:
a=np.array([1,2,3],dtype=np.int_)
print(a)
输出结果就会变成
[1 2 3]
比较纯净。