小编Mil*_*ent的帖子

Python3 类中的继承

所以 Player 类继承了 Entity 类的特性,但也有自己独特的特性,这些特性在 Player 类中初始化。

class Entity(object):
    def __init__(self, name, health, des):
        self.name = name
        self.health = health
        self.des = des
class Player(Entity):
    def __init__(self, mana):
        self.mana = mana
Run Code Online (Sandbox Code Playgroud)

这是执行此操作的正确方法吗?

python oop inheritance class python-3.x

0
推荐指数
1
解决办法
41
查看次数

标签 统计

class ×1

inheritance ×1

oop ×1

python ×1

python-3.x ×1