Python类多重继承问题演示

Python类多重继承问题演示,第1张

# _*_ coding: utf-8 _*_
__author__ = 'pythontr'
__date__ = "2022/4/28 10:30"

class TR-A():
    def getValue(self):
        print('return value of TR-A ')

    def show(self):
        print('I can show TR-A')


class TR-B(TR-A):
    def getValue(self):
        print('return value of TR-B')

class TR-C(TR-A):
    def getValue(self):
        print('return value of TR-C')

    def show(self):
        print('I can show TR-C')


class TR-D(TR-B,TR-C):
    pass

d = TR-D()
d.show()
d.getValue()

from pprint import pprint
pprint(TR-D.mro())

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/789201.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存