import numpy as np n = 5 points = np.random.randn(n, 2) p1 = points[0] p2 = points[[0,1]] p3 = points[(0,1)] list1 = points[:, 0] list2 = np.argsort(points[:, 0]) list3 = points[np.argsort(points[:, 0])]
输出
[[-0.57918598 1.14842385]
[-0.43522625 0.287748 ]
[-0.49451948 -0.68866139]
[-0.57571533 0.13939221]
[ 1.61597288 0.75871686]]
[-0.57918598 1.14842385]
[[-0.57918598 1.14842385]
[-0.43522625 0.287748 ]]
1.1484238463307976
[-0.57918598 -0.43522625 -0.49451948 -0.57571533 1.61597288]
[0 3 2 1 4]
[[-0.57918598 1.14842385]
[-0.57571533 0.13939221]
[-0.49451948 -0.68866139]
[-0.43522625 0.287748 ]
[ 1.61597288 0.75871686]]