import numpy as np
一维数组
test = [1, 2, 3, 4]
test1 = np.array([1, 2, 3, 4])
print(test1.shape)
print(test1)
print(test[2])
多为数组,矩阵
test = np.array([[1, 2, 3, 4],[7, 8, 9, 5]])
print(test.shape)
print(test)
print(test[1][2])
结果:
(4,)
[1 2 3 4]
3
(2, 4)
[[1 2 3 4]
[7 8 9 5]]
9