估计你定义的数据类型的原因,如果是 uint8,则会溢出: >>> import numpy as np >>> a = np.array([1, 2, 3], dtype = np.uint8) >>> a array([1, 2, 3], dtype=uint8) >>> a[0]=266 >>> a array([10, 2, 3], dtype=uint8) >>> a.itemsize 1 uint8的取值范围是0~255, 266-256=10.itemsize属性会返回类型字节数。
估计你定义的数据类型的原因,如果是 uint8,则会溢出:
uint8的取值范围是0~255, 266-256=10.
itemsize属性会返回类型字节数。