1. 使用 `splitlines()` 方法:
```python
text = "Hello\nWorld!"
lines = text.splitlines()
print(lines) 输出:['Hello', 'World!']
2. 使用 `split()` 方法:
```python
text = "Hello, World!"
words = text.split(", ")
print(words) 输出:['Hello', 'World!']
3. 使用正则表达式 `re` 模块:
```python
import re
text = "Hello, World!"
words = re.split(", ", text)
print(words) 输出:['Hello', 'World!']
4. 使用 `join()` 方法结合列表推导式:
```python
data = ["Hello, World!"]
lines = [item.split(", ") for item in data]
print(lines) 输出:[['Hello', 'World!']]
5. 在Pandas中拆分数据列:
```python
import pandas as pd
df = pd.DataFrame({'type': ['A,B,C', 'D,E,F']})
new_rows = df['type'].str.split(',', expand=True).stack().reset_index(drop=True).rename('type')
new_df = pd.concat([df, new_rows.to_frame().T], ignore_index=True)
print(new_df)
以上方法可以帮助你在Python中拆分多行内容。请根据你的具体需求选择合适的方法