标签:类的继承 bsp eth ini lda name 调用 info div
1 def fun(x): 2 if x > 0: 3 print "x>0" 4 else: 5 print "x<=0" 6 7 a = 3.5 8 b = -1 9 fun(a) 10 fun(b)
1 class Student: 2 def __init__(self, name, age): 3 self.name = name 4 self.age = age 5 6 def studying(self): 7 print self.name, "is studying" 8 9 def playing(self, something): 10 print self.name, "is playing", something 11 12 def info(self): 13 print "Info:", "\n",14 "Name:", self.name, "\n",15 "Age:", self.age 16 17 studentA = Student("studentA", 16) 18 studentA.studying() 19 studentA.playing("football") 20 studentA.info()
1 class A: 2 def __init__(self): 3 print "A is a parent class" 4 5 def funA(self): 6 print "funA is in class A" 7 8 class subA(A): 9 def __init__(self): 10 print "subA is a child class" 11 12 def funsubA(self): 13 print "funsubA is in class subA" 14 15 parentA = A() 16 childA = subA() 17 childA.funA() 18 childA.funsubA()
标签:类的继承 bsp eth ini lda name 调用 info div
原文地址:http://www.cnblogs.com/nightcatcher/p/6505920.html