建了兩個模塊:dom
第一個Fighter.py:spa
class Fighter(object): """戰鬥者""" __slots__ = ('_name', '_hp') def __init__(self, name, hp): """初始化方法""" self._name = name self._hp = hp
第二個Ultraman.py:code
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)blog
修改方法一:將第二個模塊的開頭修改成:from Fighter import Fighterget
修改方法二:將第二個模塊修改成:class Ultraman(Fighter.Fighter):it
具體緣由看:https://www.jianshu.com/p/5cc20b88bcf4class