为什么我除了输出之外什么也没有得到?

时间:2020-06-18 13:06:17

标签: python-3.x class oop

我不明白为什么我的代码输出

class mobile:
    def __init__(self, name, brand):
        self.name = name
        self.brand = brand

    # def get_name(self):
    #     return self.name

class cpu(mobile):
    def get_name(self):
        print(self.name)


brand = cpu("Intel","Sony")
print(brand.get_name())

输出为:

Intel
None

0 个答案:

没有答案