【问题标题】:Python 3.6 Beautiful Soup - Attribute ErrorPython 3.6 Beautiful Soup - 属性错误
【发布时间】:2017-12-05 19:31:05
【问题描述】:

我可以使用 Python 2.7 导入 BeautifulSoup,但当我尝试使用 Python 3.6 时却不能,即使 BeautifulSoup 声称两者都适用?

抱歉,这是我的第一个问题,如果它是微不足道的,或者我没有使用正确的约定,敬请见谅。

从 BeautifulSoup 导入 * 回溯(最近一次通话最后): 文件“”,第 1 行,在 文件“/Users/tobiecusson/Desktop/Python/Ch3-PythonForWebData/AssignmentWeek4/BeautifulSoup.py”,第 448 行 raise AttributeError, "'%s' object has no attribute '%s'" % (self.class.name, attr) ^ SyntaxError: 无效语法

从 BS4 导入 BeautifulSoup 回溯(最近一次通话最后): 文件“”,第 1 行,在 文件“/Users/tobiecusson/Desktop/Python/Ch3-PythonForWebData/AssignmentWeek4/BS4.py”,第 448 行 raise AttributeError, "'%s' object has no attribute '%s'" % (self.class.name, attr) ^ SyntaxError: 无效语法

【问题讨论】:

    标签: beautifulsoup python-3.6


    【解决方案1】:

    刚刚注意到 - 您正在从 BeautifulSoup 导入。 试试from bs4 import *

    【讨论】:

    • 感谢 Dimitriy,我尝试实施您的修复,但不幸的是它没有解决我的问题。
    猜你喜欢
    • 1970-01-01
    • 2014-05-31
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 2018-11-15
    • 1970-01-01
    • 1970-01-01
    • 2014-04-21
    相关资源
    最近更新 更多