import numpy as np
a=np.arange(3,15).reshape((3,4))
print(a)
print(a[2])
print(a[2,:]) #:代表这行所有数
print(a[1,0:2])
print(a[1][1])
print(a[1,1])
for row in a: #输出每一行
print(row)
输出:
[[ 3 4 5 6]
[ 7 8 9 10]
[11 12 13 14]]
[11 12 13 14]
[11 12 13 14]
[7 8]
8
8
[3 4 5 6]
[ 7 8 9 10]
[11 12 13 14]