查找array 中某个元素的位置
index = np.where(A==a)[0]
查找list 中某个元素的位置
A.index(a)
注意: array的np.where只能返回某一个元素的数值; list可以实现一组点列中删选出第一个出现该点(三维坐标)的位置值
将list中的元素转为str类型
方法一:
>>> L = [1,2,3,4,5]
>>> map(str, L)
['1', '2', '3', '4', '5']
a = [1,2,3]
b = [ str(i) for i in a ]
查找某一个三维点在一组点列中的位置,即查找重复点的位置,取三维坐标值的两位有效精度
v=[[-3.68151387e-03, -4.20966751e-01, 1.00000000e+00],
[-1.64405958e-01, -1.22046324e+00, 1.00000000e+00],
[-5.42200556e-01, -9.09887918e-01, 1.00000000e+00],
[-3.39455904e-01, -8.54805218e-01, 1.00000000e+00],
[ 5.37373562e-01, -9.11539726e-01, 1.00000000e+00],
[ 3.32122909e-01, -8.56312500e-01, 1.00000000e+00],
[ 1.58178608e-01, -1.21939329e+00, 1.00000000e+00],
[-1.10745951e+00, -3.30272672e+00, 1.00000000e+00],
[ 1.09744188e+00, -3.30336923e+00, 1.00000000e+00],
[ 1.93152989e+00, -2.72303064e+00, 1.00000000e+00],
[ 2.16004036e+00, 6.98467630e-01, 1.00000000e+00],
[-1.14289140e-03, 1.86489518e+00, 1.00000000e+00],
[ 2.16004036e+00, 6.98467630e-01, 1.00000000e+00],
[-2.17124803e+00, 6.93662998e-01, 1.00000000e+00],
[-1.14289140e-03, 1.86489518e+00, 1.00000000e+00],
[-1.94018776e+00, -2.71842407e+00, 1.00000000e+00],
[-2.17124803e+00, 6.93662998e-01, 1.00000000e+00],
[ 1.93152989e+00, -2.72303064e+00, 1.00000000e+00],
[ 1.09744188e+00, -3.30336923e+00, 1.00000000e+00],
[-1.10745951e+00, -3.30272672e+00, 1.00000000e+00],
[-1.94018776e+00, -2.71842407e+00, 1.00000000e+00]]
[[round(a,2) for a in row] for row in v]
Out[72]:
[[-0.0, -0.42, 1.0],
[-0.16, -1.22, 1.0],
[-0.54, -0.91, 1.0],
[-0.34, -0.85, 1.0],
[0.54, -0.91, 1.0],
[0.33, -0.86, 1.0],
[0.16, -1.22, 1.0],
[-1.11, -3.3, 1.0],
[1.1, -3.3, 1.0],
[1.93, -2.72, 1.0],
[2.16, 0.7, 1.0],
[-0.0, 1.86, 1.0],
[2.16, 0.7, 1.0],
[-2.17, 0.69, 1.0],
[-0.0, 1.86, 1.0],
[-1.94, -2.72, 1.0],
[-2.17, 0.69, 1.0],
[1.93, -2.72, 1.0],
[1.1, -3.3, 1.0],
[-1.11, -3.3, 1.0],
[-1.94, -2.72, 1.0]]
b=[[round(a,2) for a in row] for row in v]
b.index([-1.94, -2.72, 1.0])
Out[74]: 15
b.index([1.93, -2.72, 1.0])
Out[75]: 9