刚刚安装了BeautifulSoup Python 3.3.0

Ian*_*Ian 3 python beautifulsoup python-3.x

有谁知道如何修理它.我使用的是Mac OS 10.8.2

>>> from bs4 import BeautifulSoup
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/bs4/__init__.py", line 359
    print soup.prettify()
             ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

jfs*_*jfs 6

在Python 3中print是一个函数; 它应该是:

print(soup.prettify())
Run Code Online (Sandbox Code Playgroud)

bs4如果是错误,请正确安装或使用较新版本. beautifulsoup4==4.1.3适用于Python 3.3.