在Python中导入Beautiful Soup 4(bs4)模块的步骤如下:
1. 确保你已经安装了`beautifulsoup4`包。如果尚未安装,可以通过命令行使用`pip`进行安装:
```bash
pip install beautifulsoup4
或者如果你使用的是Python 3,请使用`pip3`:
```bash
pip3 install beautifulsoup4
2. 安装完成后,在你的Python脚本中,你可以通过以下语句导入bs4模块:
```python
from bs4 import BeautifulSoup
现在你已经成功导入了bs4模块,并可以使用它来解析HTML或XML文档。