python - "Error when calling the metaclass bases"在模块内声明类时

标签 python

首先让我说,在定义 __init__ 和运行 super()__init__ 时,我也会遇到同样的错误。我只是将它简化为这个自定义方法,看看错误是否仍然发生。

import HTMLParser

class Spider(HTMLParser):
    """
    Just a subclass.
    """

仅在模块中会引发以下错误:

Traceback (most recent call last):
  File "D:\my\path\to\my\file
    class Spider(HTMLParser):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

最佳答案

答案是我完全是个菜鸟。这是一个模块,而不是一个类,但我会把它留在这里,以防其他菜鸟遇到同样的问题。

解决方案:

from HTMLParser import HTMLParser

每次我认为自己开始成为职业选手时,都会发生这样的事情:(

关于python - "Error when calling the metaclass bases"在模块内声明类时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2253816/

相关文章:

python - 装饰器隐藏方法说明

python - 使用 Python 远程执行时 Curl 不打印

python - 使用 Python/PIL 从图像中删除背景颜色

python - 将列表字典展平为数据框

python - 根据每行中的值获取列标题

python - 停用词nltk/python问题

python - Hook Python 标准库模块

python matplotlib 如何使用类打开图像

python - sqlalchemy 中的简单更新

python - 如何提高 OpenCV 和 python VideoWriter 分辨率?