您的位置:首页 > 编程语言 > Python开发

python类初探

2016-03-30 11:28 507 查看
直接上例子:

import os

import string

class C(object):

   def __init__(self):

       print "c class"

class B(object):

    def __init__(self):

        print "this is super class"

    

    def test(self):

        print "test"

class A(C, B):

    __a = '444'

    def __init__(self, name):
'''
B.__init__(self)
'''
super(A, self).__init__()

        print 'hahaha'

        self.names = name

    def printout(self):

        super(A, self).test()

        print self.names

    

    def __del__(self):

        pass

if __name__ == '__main__':

   aobj = A('5566')

   aobj.printout()

   aobj.test()

运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 对象 class