标签:class
经典类
class A(): def __init__(self): print ‘this is a‘ def save(self): print "this is AAAAAAAA" class B(A): def __init__(self): print ‘this is BBBBBBBB‘ class C(A): def __init__(self): print ‘this is C‘ def save(self): print ‘this is CCCCCCCCCCCCC‘ class D(B,C): def __init__(self): print ‘this is D‘ c = D() c.save() #输入结果 this is D this is AAAAAAAA
新式类
class A(object): def __init__(self): print ‘this is a‘ def save(self): print "this is AAAAAAAA" class B(A): def __init__(self): print ‘this is BBBBBBBB‘ class C(A): def __init__(self): print ‘this is C‘ def save(self): print ‘this is CCCCCCCCCCCCC‘ class D(B,C): def __init__(self): print ‘this is D‘ c = D() c.save() #输入结果 this is D this is CCCCCCCCCCCCC
本文出自 “Dream chaser” 博客,请务必保留此出处http://dreamchaser.blog.51cto.com/7756851/1964656
标签:class
原文地址:http://dreamchaser.blog.51cto.com/7756851/1964656