1. 使用 `open()` 函数:
```python
with open('file.txt', 'r') as file:
content = file.read()
print(content)
2. 使用 `with` 语句和 `read()` 方法:
```python
with open('file.txt', 'r') as file:
content = file.read()
print(content)
3. 使用 `with` 语句和 `readline()` 方法逐行读取文件内容:
```python
with open('file.txt', 'r') as file:
line = file.readline()
while line:
print(line)
line = file.readline()
4. 使用 `with` 语句和 `readlines()` 方法将文件内容读取为列表:
```python
with open('file.txt', 'r') as file:
lines = file.readlines()
for line in lines:
print(line)
5. 使用 `io.open()` 函数(来自 `io` 模块),提供面向对象的接口:
```python
import io
with io.open('file.txt', 'r', encoding='utf-8') as file:
content = file.read()
print(content)
请根据你的需求选择合适的方法来读取文件内容。