soup = BeautifulSoup(f, 'xml')
NameError: name 'BeautifulSoup' is not defined
打开文件,发现需要导入
from bs4 import BeautifulSoup
这是解析数据集需要的。然后
pip install bs4
但是出现新的错误:
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?
再安装lxml
pip install lxml
现在可以运行了。
本文介绍了在使用BeautifulSoup解析XML数据时遇到的NameError错误及解决方案,随后解决了FeatureNotFound错误,通过安装lxml库成功运行程序。
1万+

被折叠的 条评论
为什么被折叠?



