1. 使用 `math.floor()` 函数:
```python
import math
x = 3.5
y = math.floor(x)
print(y) 输出:3
2. 使用整除操作符 `//`:
```python
x = 7.8
y = x // 1
print(y) 输出:7
3. 使用 `numpy.floor()` 函数(如果需要使用NumPy库):
```python
import numpy as np
x = 7.8
y = np.floor(x)
print(y) 输出:7.0
4. 使用 `int()` 函数(注意:这将直接截断小数部分,而不是向下取整):
```python
x = 12.66
y = int(x)
print(y) 输出:12
选择哪种方法取决于你的具体需求