python,.unique
时间: 2023-10-17 12:11:24 浏览: 64
Python flask.docx
In Python, `.unique` is not a built-in method or function. However, the NumPy library has a method called `np.unique()` that returns the unique elements of an array.
Here is an example of how to use `np.unique()`:
```python
import numpy as np
arr = np.array([1, 2, 3, 1, 2, 4, 5, 4])
unique_arr = np.unique(arr)
print(unique_arr)
```
Output:
```
[1 2 3 4 5]
```
In this example, `np.unique()` takes an array `arr` and returns a new array `unique_arr` with only the unique elements of `arr`.
阅读全文