http://blog.csdn.net/lanchunhui/article/details/55657040
>>> g = np.array([[ 40.47109199 , -10.01622954 , 275.29573762 , 311.23186909 , 0.99994779]]
>>> print g
[[ 40.47109199 -10.01622954 275.29573762 311.23186909 0.99994779]]
>>> len(g)
1
>>> g.shape
(1, 5)
import numpy as np x = np.array([[[0], [1], [2]]]) print(x) """ x= [[[0] [1] [2]]] """ print(x.shape) # (1, 3, 1) x1 = np.squeeze(x) # 从数组的形状中删除单维条目,即把shape中为1的维度去掉 print(x1) # [0 1 2] print(x1.shape) # (3,)
>>> y1 = np.array([[ 40.47109199 , -10.01622954 , 275.29573762 , 311.23186909 , 0.99994779]]) >>> y1 array([[ 40.47109199, -10.01622954, 275.29573762, 311.23186909, 0.99994779]]) >>> y1[0,0:4] array([ 40.47109199, -10.01622954, 275.29573762, 311.23186909]) >>> y1[0,0:0] array([], dtype=float64) >>> y1[0,0:1] array([ 40.47109199]) >>> y1[0,0:5] array([ 40.47109199, -10.01622954, 275.29573762, 311.23186909, 0.99994779])