覆盖python抽象方法时,有没有办法在方法签名中使用额外的参数覆盖该方法?
例如
抽象类=
Agent(ABC):
@abstractmethod
def perceive_world(self, observation):
pass
Run Code Online (Sandbox Code Playgroud)
继承类:
Dumb_agent(Agent):
def perceive_world(self, observation):
print('I see %s' % observation)
Run Code Online (Sandbox Code Playgroud)
在方法签名中使用额外参数继承类:
Clever_Agent(Agent):
def perceive_world(self, observation, prediction):
print('I see %s' % observation)
print('I think I am going to see %s happen next' % prediction)
Run Code Online (Sandbox Code Playgroud)