建了两个模块:

第一个Fighter.py:

python继承初始化对象实例时 TypeError: module() takes at most 2 arguments (3 given)
class Fighter(object):
    """战斗者"""
    __slots__ = ('_name', '_hp')

    def __init__(self, name, hp):
        """初始化方法"""
        self._name = name
        self._hp = hp
python继承初始化对象实例时 TypeError: module() takes at most 2 arguments (3 given)

第二个Ultraman.py:

python继承初始化对象实例时 TypeError: module() takes at most 2 arguments (3 given)
import Fighter
from random import randint


class Ultraman(Fighter):
    """奥特曼"""
    __slots__ = ('_name', '_hp', '_mp')

    def __init__(self, name, hp, mp):
        self._name = name
        self._hp = hp
        self._mp = mp
python继承初始化对象实例时 TypeError: module() takes at most 2 arguments (3 given)

运行显示错误:TypeError: module() takes at most 2 arguments (3 given)

修改方法一:将第二个模块的开头修改为:from Fighter import Fighter

修改方法二:将第二个模块修改为:class Ultraman(Fighter.Fighter):

具体原因看:https://www.jianshu.com/p/5cc20b88bcf4

相关文章:

  • 2021-08-31
  • 2022-12-23
  • 2021-08-17
  • 2021-09-22
  • 2022-12-23
  • 2021-11-07
  • 2021-07-28
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2021-09-18
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-07-06
相关资源
相似解决方案