我正在尝试创建一个程序,从网页中获取一组数字并将它们相加。我使用了我安装的beautifulsoup模块(在命令提示符下运行“pip install beutifulSoup4”)
代码:
from bs4 import BeautifulSoup
web=request.urlopen('http://py4e-data.dr-chuck.net/comments_845350.html').read()
x = BeautifulSoup(html)
tags=x('span')
sum=0
for tag in tags:
sum = sum+int(tag.contents[0])
print(sum)
但是,每当我运行程序时,python都会给我一个ModuleNotFoundError:没有名为bs4的模块。我如何修复这个问题
如果你看here,你会看到
pip install beautifulsoup4
应该做这项工作如果您使用的是Linux,则可能必须改用
pip3
您的机器上是否安装了多个版本的Python
如果是这样,试着跑步
会返回这样的东西吗
然后验证是否使用相同的版本运行脚本
相关问题 更多 >
编程相关推荐