标签:import sel copy slot pre object module href argument
建了两个模块:
第一个Fighter.py:
class Fighter(object): """战斗者""" __slots__ = (‘_name‘, ‘_hp‘) def __init__(self, name, hp): """初始化方法""" self._name = name self._hp = hp
第二个Ultraman.py:
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
运行显示错误:TypeError: module() takes at most 2 arguments (3 given)
修改方法一:将第二个模块的开头修改为:from Fighter import Fighter
修改方法二:将第二个模块修改为:class Ultraman(Fighter.Fighter):
具体原因看:https://www.jianshu.com/p/5cc20b88bcf4
python继承初始化对象实例时 TypeError: module() takes at most 2 arguments (3 given)
标签:import sel copy slot pre object module href argument
原文地址:https://www.cnblogs.com/shengs/p/13159600.html