python数组
zzz1007
这个作者很懒,什么都没留下…
展开
-
python中numpy.reshape()
>>> import numpy as np>>> x = np.array([[2, 4], [3, 1], [7, 8]])>>> y = x.reshape(3,2) #指定新数组行为3,列为2>>> print(y)[[2 4] [3 1] [7 8]]>>> y = x.reshape(-1,1) #指定新数组列为1>>> print(y)[[2] [4] [3]原创 2021-03-17 16:02:32 · 285 阅读 · 0 评论 -
python一维二维数组取行取列:,-1应用
import numpy as np>>> a=np.arange(1,6)>>> print(a)[1 2 3 4 5]>>> print(a[-1]) #取最后一个数5>>> print(a[:-1]) #只不取最后一个数[1 2 3 4]>>> print(a[::-1]) #翻转取数[5 4 3 2 1]>>> print(a[2::-1]) #翻转数原创 2021-03-17 15:22:18 · 1790 阅读 · 0 评论