社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
import tensorflow as 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前两行,前两列元素
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!