2020
10-07
10-07
numpy的Fancy Indexing和array比较详解
一:FancyIndexingimportnumpyasnp#FancyIndexingx=np.arange(16)np.random.shuffle(x)print(x)#打印所有的元素print(x[2])#获取某个元素的值print(x[1:3])#切片print(x[3:9:2])#指定间距切片index=[2,4,7,9]#索引数组print(x[index])#获取索引数组中的元素的值ind=np.array([[0,2],[1,4]])#索引二维数组print(x[ind])##获取索引二维数组中的元素的值print("---------------------")X=x.reshape(4,-1)print...
继续阅读 >