python构造函数示例

2015-08-26 0 714
python构造函数示例
# 

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()

遇见资源网 python python构造函数示例 http://www.ox520.com/15716.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务