class Camera():
def take_photo(self):
print("拍照")
class MP3():
def play_mp3(self):
print("播放MP3")
class Iphone(Camera,MP3):
def nfc(self):
print("NFC 功能")
# 多类继承
iphone = Iphone()
iphone.take_photo()
iphone.play_mp3()
iphone.nfc()
Python - 多类继承
阅读 82
2023-03-22
class Camera():
def take_photo(self):
print("拍照")
class MP3():
def play_mp3(self):
print("播放MP3")
class Iphone(Camera,MP3):
def nfc(self):
print("NFC 功能")
# 多类继承
iphone = Iphone()
iphone.take_photo()
iphone.play_mp3()
iphone.nfc()
相关推荐
精彩评论(0)