Python 中class的小例子
class Song():
def __init__(self,lyrics):
self.lyrics=lyrics
def sing_a_song(self):
for line in self.lyrics:
print(line)
happy=Song(["Happy birthday to you",
"Happy birthday to you"])
happy.sing_a_song()
class Song(object):
def __init__(self):
self.tang="lyrics"
def sing(self):
print("I wanna sing a song")
thing=Song()
thing.sing()
print(thing.tang)
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
更多精彩

