Traceback (most recent call last): File "D:\python_project\test1.py", line 1, in <module> from bs4 import BeautifulSoup File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 945, in _find_spec File "<frozen importlib._bootstrap_external>", line 1439, in find_spec File "<frozen importlib._bootstrap_external>", line 1411, in _get_spec File "<frozen zipimport>", line 170, in find_spec File "<frozen importlib._bootstrap>", line 431, in spec_from_loader File "<frozen importlib._bootstrap_external>", line 741, in spec_from_file_location File "<frozen zipimport>", line 229, in get_filename File "<frozen zipimport>", line 760, in _get_module_code File "<frozen zipimport>", line 689, in _compile_source File "D:\python\python3.10.7\lib\site-packages\beautifulsoup4-4.3.2-py3.10.egg\bs4\__init__.py", line 175 except Exception, e: ^^^^^^^^^^^^ SyntaxError: multiple exception types must be parenthesized
时间: 2023-06-10 10:07:37 浏览: 961
linux 下 pip3 报错“ File “/usr/bin/pip3”, line 9, in from pip import mainImportError: canno”处理
5星 · 资源好评率100%
这个错误是因为你的代码使用了 Python 2.x 的语法,而你正在使用 Python 3.x 运行它。在 Python 3.x 中,抛出异常时,多个异常类型必须用圆括号括起来。你需要将代码中所有的 except 语句修改为以下格式:
```
except (Exception, e):
```
或者,如果你只想处理特定类型的异常,只需要在括号中列出这些异常类型即可。例如:
```
except ImportError as e:
```
阅读全文