ex40模块类和对象
作者:互联网
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(["There rally around the family",
"With pockets full of shells"])
happy_bday.sing_me_a_song()
bulls_on_parade.sing_me_a_song()
标签:me,lyrics,Song,对象,self,ex40,模块,sing,song 来源: https://www.cnblogs.com/l-y-l/p/12710341.html