python的设计模式,python设计模式,# encoding=u


# encoding=utf-8  def printInfo(info):      print unicode(info, 'utf-8').encode('gbk')  class Person():      name = ""      def __init__(self, name):          self.name = name;          return;      def Show(self):          printInfo("zhuangbanhao%s" % self.name)  class Finery(Person):      component = None      def __init__(self):          return;      def Decorate(self, component):          self.component = component      def Show(self):          if(None != self.component):              self.component.Show()  class BigTrouser(Finery):      def Show(self):          printInfo("ku_zi")            self.component.Show()        class TShirts(Finery):      def Show(self):          printInfo("t_shirt")          self.component.Show()  def clientUI():      xc = Person("xiaocai")      bT = BigTrouser()      TS = TShirts()      bT.Decorate(xc)      TS.Decorate(bT)      TS.Show()      return  if __name__ == '__main__':      clientUI(); 

评论关闭