# -*- coding: UTF-8 -*- class A(object): def __init__(self,xing,gender): #!#1 self.namea="aaa" #!#2 self.xing = xing #!#3 self.gender = gender #!#4 def funca(self): print "function a : %s"%self.namea import A class B(A): def __init__(self,xing,age): #!#5 super(B,self).__init__(xing,age) #!#6(age处应为gender) self.nameb="bbb" #!#7 ##self.namea="ccc" #!#8 ##self.xing = xing.upper() #!#9 self.age = age #!#10 def funcb(self): print "function b : %s"%self.nameb ##output b=B("lin",22) #!#11 print b.nameb print b.namea print b.xing #!#12 print b.age #!#13 b.funcb() b.funca()
python继承
阅读:3911 输入:2018-12-15 08:44:22
- 上一篇:关于eclipse对齐JS代码的问题
- 下一篇:一个class设置多个样式表