1
Traceback (most recent call last):
File "bs4.py", line 1, in <module>
import bs4
File "/home/mhadi/Desktop/bs4test/bs4.py", line 5, in <module>
soup = bs4.BeautifulSoup(site,'lxml')
AttributeError: module 'bs4' has no attribute 'BeautifulSoup'
代碼:AttributeError的:模塊 'BS4' 有沒有屬性 'BeautifulSoup'
import bs4
import urllib.request
site = urllib.request.urlopen('http://127.0.0.1:8000').read()
soup = bs4.BeautifulSoup(site,'lxml')
#for i in site:
# print(site[i])
print(soup)
'然後直接使用'BeautifulSoup' – rednaks
我想你不應該命名您的文件'bs4'因爲它會造成混亂。 –