Python是什么鬼?找孙悟空要解释吧?
Python是一门人与计算机交流的JJ语言。。。。。
设计模式了解下?点到为止科普点点?
是一套被反复使用,经过分类编目、代码设计经验的总结,它可以重用代码、让代码更容易被他人理解、保证代码可靠性。
来两段?工厂模式下的玩两下。。。。。
class ShapeFactory(object): def getShape(self): return self.shape_name class Circle(ShapeFactory): def __init__(self): self.shape_name = 'Circle' def draw(self): print('draw circle') class Rectangle(ShapeFactory): def __init__(self): self.shape_name = "Retangle" def draw(self): print('draw Rectangle') class Shape(object): def create(self,shape): if shape == 'Rectangle': return Rectangle() elif shape == 'Circle': return Circle() else: return None fac = Shape() obj = fac.create('Circle') obj.draw() obj.getShape()