首页 > 其他 > 详细

Exercise 40: Modules, Classes, And Objects

时间:2014-10-26 12:57:36      阅读:293      评论:0      收藏:0      [点我收藏+]
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()

 

Exercise 40: Modules, Classes, And Objects

原文:http://www.cnblogs.com/hluo/p/4051799.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!