30/09/2018, 23:02
Thắc mắc về Class, trong trỏ self trong python
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 stop right there.”])
bulls_song_parade = Song([“They rally around the family”,
“with pockets full of shells.”])
happy_bday.sing_me_a_song()
bulls_song_parade.sing_me_a_song()
Bài liên quan
Bạn có thể dùng chức năng search của diễn dàn để tìm hiểu về `self: