标签:color style none 信息 def __init__ sel 继承 gre
class CLASSNAME(base)
‘’‘类的帮助信息’‘’
statement
class Fruit: color=‘green‘ def harvest(self,color): print(‘I am %s‘%color) print(Fruit.color) class Apple(Fruit): color = ‘red‘ def __init__(self): print(‘apple‘) class Orange(Fruit): color=‘yellow‘ def __init__(self): print(‘orange‘) a=Apple() o=Orange() print(a.harvest(Apple.color)) print(o.harvest(Orange.color))
》》》》
apple
orange
I am red
green
None
I am yellow
green
None
标签:color style none 信息 def __init__ sel 继承 gre
原文地址:https://www.cnblogs.com/python1988/p/12199156.html