python提示SongBird instance has no attribute 'sound'
大家讲道理
大家讲道理 2017-04-18 09:38:09
0
1
428

提示SongBird instance has no attribute 'sound'

_metaclass_ = type
class Bird:
    def _init_(self):
        self.hungry = True
    def eat(self):
        if self.hungry:
            print 'Aaaaa.....'
            self.hungry = False
        else:
            print 'No, think'

class SongBird(Bird):
    def _init_(self):
        super(SongBird, self)._init_()
        self.sound = 'Squawk!'
    def sing(self):
        print self.sound

sb = SongBird( )
sb.sing( )

刚开始学python,这是书上的代码。检查过很多遍,就是通不过。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(1)
阿神

雷雷

__init__不是_init_

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板