python中的类怎么继承
1个回答
2018-01-23 · 知道合伙人互联网行家
关注
展开全部
#-*- coding:utf-8 -*-class Animal(object):
"""docstring for Animal"""
def __init__(self, name):
self.name = name def run(self):
print 'Animal is running...'class Dog(Animal):
"""docstring for Dog"""
def __init__(self,name):
# super(Dog, self).__init__(name)
Animal.__init__(self,name) def printName(self):
print 'Name: %s' % self.name
kk=Dog("kity")
kk.printName()
kk.run()
"""docstring for Animal"""
def __init__(self, name):
self.name = name def run(self):
print 'Animal is running...'class Dog(Animal):
"""docstring for Dog"""
def __init__(self,name):
# super(Dog, self).__init__(name)
Animal.__init__(self,name) def printName(self):
print 'Name: %s' % self.name
kk=Dog("kity")
kk.printName()
kk.run()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询