ITPub博客

首页 > 应用开发 > > python 实例化对象 报错问题

python 实例化对象 报错问题

作者:luckybird 时间:2019-09-03 10:11:01 0 删除 编辑

class People():

def init(self,height,money):

self.height=height

self.money=money

class Man(People):

def init(self,age):

self.age = age

Man(11,22)

TypeError: init() takes 2 positional arguments but 3 were given

[](https://img2018.cnblogs.com/q/1296045/201903/1296045-20190328140226935-1631748365.png

子类 Man() 初始化函数 只需要传入 1个参数,实例化时 传入 2个参数, 但是 错误提示 说 传入了3个, 是什么原因

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1377/viewspace-3158946/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    113
  • 访问量
    1389