import numpy as np
#索引与列表相同
# nparr1=np.arange(0,10)
# print(nparr1) # [0 1 2 3 4 5 6 7 8 9]
# nparr1[1]=10
# nparr1[-1]=15
# print(nparr1)
# print(nparr1[-1]) #9
# print(nparr1[1]) #1
#可见,索引与列表相同
# for i in nparr1:
# print(i,end=" ")
# nparr2=np.arange(0,12).reshape(3,4)
# print(nparr2)
# print(nparr2[2][1]) #相当于一个二维数组的访问
#切片
# nparr3=np.arange(0,12)
# print(nparr3[:5])
# nparr4=np.arange(0,12).reshape(3,4)
# print(nparr4)
# # print(nparr4[2][1:4]) #多维的切片,与列表一样
# print(nparr4[1:])
#数组复制copy()
# nparr5=np.arange(0,12)
# print(nparr5)
# nparr6=nparr5.copy() #不共内存地址
# nparr6[0]=20
# print(nparr6)
# nparr7=nparr6 #共内存地址,
# nparr7[0]=30
# print(nparr7)
# print(nparr6)
# nparr8=np.arange(0,12).reshape(4,3)
# print(nparr8)
# nparr9=nparr8.copy()
# print(nparr9)
原文地址:https://www.cnblogs.com/yiyea/p/11441748.html