1 import numpy as np 2 3 x = np.array([1, 2, 2.5]) 4 print(x.dtype) 5 x.astype(int) 6 print(x.dtype) 7 8 y = np.array([3, 6, 2], dtype=‘S32‘) 9 print(y.dtype) 10 y = y.astype(‘float64‘) 11 print(y.dtype) 12 print(x-y) 13 14 结果: 15 float64 16 float64 17 |S32 18 float64 19 [-2. -4. 0.5]
python 两个numpy矩阵维度相同,相减却报错了???
原文:https://www.cnblogs.com/Susie2world/p/12853743.html