2016-03-29 64 views
1

使用時使用的代碼'BeautifulSoup' 有沒有屬性 '__version__'

from bs4 import BeautifulSoup 
print ("BeautifulSoup version:%6.6s" %BeautifulSoup.__version__) 

我得到這個錯誤

AttributeError: type object 'BeautifulSoup' has no attribute 'version'

我使用python setup.py的安裝安裝BS4 jupyter筆記本。它顯示在安裝「c:\ users ... \ anaconda3 \ lib \ site-packages \ beautifulsoup4-4.4.1-py3.5.egg」

回答

5

對於BeautifulSoup版本4,您應該這樣做相反:

>>> import bs4 
>>> print ("BeautifulSoup version:%6.6s" % bs4.__version__) 
BeautifulSoup version: 4.4.1 
+0

感謝您的幫助! – Raf8

相關問題