首页 新闻 会员 周边 捐助

在Python导入bs4库文件时报错怎么解决?

0
[已解决问题] 解决于 2017-09-21 10:44

在IDLE中运行结果:

Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

>>> import bs4
>>>

bs的版本为:

在PyCharm编译器上时报错:


python版本

一叶*秋的主页 一叶*秋 | 初学一级 | 园豆:5
提问于:2017-08-21 14:53
< >
分享
最佳答案
0

from bs4 import BeautifulSoup

奖励园豆:5
北方姆Q | 小虾三级 |园豆:1120 | 2017-08-21 15:33

C:\Users\Administrator\AppData\Local\Programs\Python\Python35\python.exe D:/python/style/style-1/bianliang-01.py
Traceback (most recent call last):
File "D:/python/style/style-1/bianliang-01.py", line 64, in <module>
app.get_content()
File "D:/python/style/style-1/bianliang-01.py", line 45, in get_content
all_h2=self.get_all_h2() #所有的数据都获取出来了
File "D:/python/style/style-1/bianliang-01.py", line 34, in get_all_h2
html = self.get_one_page_html()
File "D:/python/style/style-1/bianliang-01.py", line 27, in get_one_page_html
re = requests.get(self.url, self.headers)
TypeError: get() takes 1 positional argument but 2 were given

Process finished with exit code 1

#这算是成功了还是出错了呢?

一叶*秋 | 园豆:5 (初学一级) | 2017-08-21 15:40

@一叶*秋: 导入正确,你程序里传参错误

北方姆Q | 园豆:1120 (小虾三级) | 2017-08-21 15:41

@北方姆Q: 谢谢你呀,之前也用的是bs4结果不起作用,不过现在好了

一叶*秋 | 园豆:5 (初学一级) | 2017-08-21 15:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册