51Testing软件测试论坛

标题: python3 运行super() 报错 [打印本页]

作者: heep789    时间: 2018-4-26 16:53
标题: python3 运行super() 报错
import random as r
class Fish:
    def __init__(self):
        self.x = r.randint(0,10)
        self.y = r.randint(0,10)
    def move(self):
        self.x -= 1
        print("my site is : " ,self.x,self.y)

class Shark(Fish):
    def __init__(self):
        super().__init__()
        self.hungry =True
    def eat(self):
        if self.hungry:
            print('My dream is eating everyday!')
            self.hungry=False
        else:
            print('Too much ,Too much!!!')
shark = Shark()   
报错TypeError: super() takes at least 1 argument (0 given)
求大神们指点~~~~,super().__init__()   哪有问题呀。。是在python3上运行的。






欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2