下面,我们分别创建了一个 Python 数组和 NumPy 数组:
# python array
a = [1,2,3,4,5,6,7,8,9]
# numpy array
A = np.array([...([ 2, 7, 12, 17, 22, 27])
其实在 NumPy 中的数组可以等价的称之为矩阵或向量。...1,其它元素都为 0。...([[4, 1, 7],
[5, 2, 8],
[6, 3, 9]])
np 数组索引
NumPy 数组的索引方式和 Python 列表的索引方式是一样的,从零索引数组的第一个元素开始我们可以通过序号索引数组的所有元素...,注意 Python 列表和数组的索引都是左闭右开,即 A 中包含 2 索引的元素而不包含 5 索引的元素:
A[lowerbound(inclusive): upperbound(exclusive)