'BeautifulSoup'没有属性'__version__'

Raf*_*af8 3 python beautifulsoup ipython

使用jupyter笔记本时使用代码

from bs4 import BeautifulSoup
print ("BeautifulSoup version:%6.6s" %BeautifulSoup.__version__)
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误

AttributeError:类型对象'BeautifulSoup'没有属性' version '

我使用python setup.py install安装了bs4.它在安装中显示"c:\ users ...\anaconda3\lib\site-packages\beautifulsoup4-4.4.1-py3.5.egg"

har*_*r07 9

对于BeautifulSoup版本4,您应该这样做:

>>> import bs4
>>> print ("BeautifulSoup version:%6.6s" % bs4.__version__)
BeautifulSoup version: 4.4.1
Run Code Online (Sandbox Code Playgroud)