tf
import numpy as np
# one-dimention
a = np.array([0,1,2,3,4,5,6,7,8,9])
print(a)
b=a[:4]
print(b)
c=...a[4:]
print(c)
# multi-dimention
d = np.array([[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9,0],[2,3,4,5,6,7,8,9,0,1...]])
print(d)
e=d[:2,:5]
print(e)
b:截取a前4个元素
c: 截取a后6个元素
e: 截取d前两行,前两列元素
发布者:全栈程序员栈长,转载请注明出处:https