美文网首页
好好敲代码

好好敲代码

作者: Don_t_Panic | 来源:发表于2015-04-17 21:28 被阅读0次

总算开始学类了,上次就是在这over的。

class Song(object):
 def __init__(self, lyrics):
  self.lyrics = lyrics
 def sing_me_a_song(self):
  for line in self.lyrics:
   print line
happy_bday = Song(["Happy birthday to you",
 "I don't want to get sued",
 "So I'll stop right there"])
bulls_on_parade = Song(["They rally around the family",
 "With pockets full of shells"])
happy_bday.sing_me_a_song()
bulls_on_parade.sing_me_a_song()

相关文章

网友评论

      本文标题:好好敲代码

      本文链接:https://www.haomeiwen.com/subject/rwwkfttx.html