python object takes no parameters

 1 class Song(object):
 2     def __init__(self,lyrics):
 3         self.lyrics = lyrics
 4         
 5     def sing_me_a_song(self):
 6         for line in self.lyrics:
 7             print line
 8         
 9 happy_bday = Song(["happy birthday to you "," I dont want to get sued","so i'll stop right there"])
10 
11 
12 bulls_on_parade = Song(["they rally around the family",
13                         "with pocket full of sheells"])
14                         
15 happy_bday.sing_me_a_song()
16 bulls_on_parade.sing_me_a_song()
View Code

def __init__(self,lyrics):

错误出在这个地方,init前后是两个_下划线,而不是一个

posted on 2016-11-25 13:43  小唐师叔  阅读(375)  评论(0编辑  收藏  举报