性夜影院午夜看片,无码精品久久一区二区三区,婷婷成人丁香五月综合激情,校园春色 qvod,性调教室高h学校

Python面試真題 - Python編程: 類繼承

【Python面試真題】- Python編程: 類繼承

def class_test():
class A(object):
def show(self):
print("class A")

    def hello(self):
        print("hello")

class B(A):
    def show(self):
        print("class B")

b =B()
b.show()
b.hello()
# 調用類A的show方法
b.__class__ = A
b.show()  
# __class__方法指向了類對象,只用給他賦值類型A,
# 然后調用方法show,但是用完了記得修改回來。
"""OUT
class B
hello
class A



相關新聞

歷經(jīng)多年發(fā)展,已成為國內(nèi)好評如潮的Linux云計算運維、SRE、Devops、網(wǎng)絡安全、云原生、Go、Python開發(fā)專業(yè)人才培訓機構!