22. 计算数组a = np.array([1,2,3,2,3,4,3,4,5,6])和数组b = np.array([7,2,10,2,7,4,9,4,9,8])之间的欧式距离。
时间: 2023-08-19 17:23:56 浏览: 59
可以使用NumPy库中的linalg.norm函数来计算欧式距离。代码如下:
```python
import numpy as np
a = np.array([1,2,3,2,3,4,3,4,5,6])
b = np.array([7,2,10,2,7,4,9,4,9,8])
dist = np.linalg.norm(a-b)
print(dist)
```
输出结果为:
```
14.212670403551895
```
阅读全文