首先,使用面向对象是一个人狗大战的实例:
class Person: def __init__(self, name, hp, aggr, sex): self.name = name self.hp = hp self.aggr = aggr self.sex = sex def hit(self, dog): dog.hp -= self.aggr print('