Python 脉冲群误差

Python 脉冲群误差,python,beautifulsoup,Python,Beautifulsoup,结果是错误的 import urllib import urllib.request from bs4 import BeautifulSoup theurl = "https://twitter.com/official_YDP09" thepage = urllib.request.urlopen(theurl) soup = BeautifulSoup(thepage, "html.parser") print(Soup.title) C:\Users\Yohan\AppData\L

结果是错误的

import urllib
import urllib.request
from bs4 import BeautifulSoup

theurl = "https://twitter.com/official_YDP09"
thepage = urllib.request.urlopen(theurl)
soup = BeautifulSoup(thepage, "html.parser")

print(Soup.title)
C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\Python.exe“C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py”
回溯(最近一次呼叫最后一次):
文件“C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py”,第7行,在
soup=BeautifulSoup(页面“html.parser”)
文件“C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\lib\site packages\bs4\\uuuu init\uuu.py”,第153行,在\uu init中__
builder=builder\u class()
文件“C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\lib\site packages\bs4\builder\u htmlparser.py”,第39行,在初始化中__
返回super(HTMLParserTreeBuilder,self)。\uuuuuu init\uuuuu(*args,**kwargs)
TypeError:\uuuu init\uuuuuuu()获得意外的关键字参数“strict”
进程已完成,退出代码为1

您必须更改该字符串:

C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py"
Traceback (most recent call last):
  File "C:/Users/Yohan/PycharmProjects/Project/aku pasti bisa.py", line 7, in <module>
    soup = BeautifulSoup(thepage, "html.parser")
  File "C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bs4\__init__.py", line 153, in __init__
    builder = builder_class()
  File "C:\Users\Yohan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bs4\builder\_htmlparser.py", line 39, in __init__
    return super(HTMLParserTreeBuilder, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'strict'

Process finished with exit code 1
将打印(Soup.title)更改为打印(Soup.title)的短修复程序 汤是小写的。 尝试从urllib切换到。希望这有帮助,如果没有请让我们知道

编辑1:添加结果的图像

我得到了输出

我发现的区别是, 打印(soup.title)#这里您使用的是大写的soup

如果问题没有解决,请将beautifulsoup重新安装到正确的版本中。您需要4.4+版本,因为您使用的是python 3.6+

soup = BeautifulSoup(thepage.read(), "html.parser")
不需要,因为您已经
导入urllib

您使用的是python3,因此请使用

import urllib.request 
如果您没有
pip3
请使用
apt-get-install-python3-pip


我尝试过,结果是:回溯(最近一次调用最后一次):文件“test.py”,第3行,从bs4导入BeautifulSoup模块NotFoundError:没有名为“bs4”的模块请检查我的答案@YohanesDwiPratama,因为您使用的是python 3,所以需要再次安装bs4
pip3 install beautifulsoup4