查询类:
class Trace(): def Lookup(self): #查询其子类设置的内容 self.HeadFormat = "%-*s%*s" self.Bwidth = len(self.Booktime);self.Awidth = len(self.Arrivetime) self.Swidth = len(self.Status);self.Lwidth = len(self.Location) self.Hwidth = self.Bwidth + self.Awidth + self.Swidth + self.Lwidth self.Hvar = self.Hwidth + 10 print self.Hvar * '-' print self.HeadFormat % (4,'Item',self.Hvar-4,'Info') print self.Hvar * '=' print self.HeadFormat % (8,'Booktime:',self.Hvar-8,self.Booktime) print self.HeadFormat % (10,'Arrivetime:',self.Hvar-10,self.Arrivetime) print self.HeadFormat % (6,'Status:',self.Hvar-6,self.Status) print self.HeadFormat % (8,'Location:',self.Hvar-8,self.Location) print self.Hvar * '-'
class Set(Trace): def SetVar(self): #设置相关信息 self.Booktime = str(raw_input("Please input the Booktime:")) self.Arrivetime = str(raw_input("Please input the Arrivetime:")) self.Status = str(raw_input("Please input the Status:")) self.Location = str(raw_input("Please input the Location:"))