1. 程式人生 > >python super()繼承父類

python super()繼承父類

class sed bar 繼承 print opened 分享 self. cnblogs

技術分享
class Foo(object):
  def __init__(self, frob, frotz):
    self.frobnicate = frob
    self.frotz = frotz

class Bar(Foo):
  def __init__(self, frob, frizzle):
    super(Bar,self).__init__(frob,34)
    self.frazzle = frizzle

new = Bar("hello","world")
print (new.frobnicate )
print (new.frazzle )
print (new.frotz ) >>> hello world 34
View Code

python super()繼承父類