python构造函数示例

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

# 

class Critter(object):
    '''A virtual pet''' 
    def __init__(self):
        print 'A new critter has been born!'

    def talk(self):
        print '\nHi.  I'm an instance of class Critter.'

# main
crit1 = Critter()
crit2 = Critter()

crit1.talk()
crit2.talk()