gpt4 book ai didi

python - 导入错误 : No module named BeautifulSoup

转载 作者:IT老高 更新时间:2023-10-28 21:32:55 26 4
gpt4 key购买 nike

我已经使用 easy_install 安装了 BeautifulSoup 并尝试运行以下脚本

from BeautifulSoup import BeautifulSoup
import re

doc = ['<html><head><title>Page title</title></head>',
'<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',
'<p id="secondpara" align="blah">This is paragraph <b>two</b>.',
'</html>']
soup = BeautifulSoup(''.join(doc))

print soup.prettify()

但不知道为什么会这样

Traceback (most recent call last):
File "C:\Python27\reading and writing xml file from web1.py", line 49, in <module>
from BeautifulSoup import BeautifulSoup
ImportError: No module named BeautifulSoup

你能帮忙吗?谢谢

最佳答案

试试这个from bs4 import BeautifulSoup

这可能是 Beautiful Soup 第 4 版和测试版的问题。我刚从主页上读到这个。

关于python - 导入错误 : No module named BeautifulSoup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5663980/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com