import numpy as np
a = np.array([[1,2], [3, 4], [5, 6]])
print a[[0, 1, 2], [0, 1, 0]] # Prints "[1 4 5]" 这什么意思,我怎么不懂 给解释一下
1
110male OP a = np.array([[1,2], [3, 4], [5, 6]])
print a[[0, 1, 2], [0, 1, 0]] 结果是: "[1 4 5]" 什么意思? |
2
z0z 2017-12-25 15:29:55 +08:00 1
import numpy as np
a = np.array([[1,2],[3,4],[5,6]]) print(a[[0,1,2]]) print("=========") print(a[[0,1,0]]) print("=========") print(a[[0,1,2],[0,1,0]]) [[1 2] [3 4] [5 6]] ========= [[1 2] [3 4] [1 2]] ========= [1 4 5] Process finished with exit code 0 |
3
ProkillerJ 2017-12-25 20:03:57 +08:00 1
a[[x1, x2, x3], [y1, y2, y3]] 相当于[a[x1,y1],a[x2,y2],a[x3,y3]]
|