标签:sage nbsp 技术 多个 分享图片 功能 [] name cts
一个从多个父类继承过来的子类,可以访问所有父类的功能。

class Contact:
all_contacts = []
def __init__(self, name, email):
self.name = name
self.email = email
Contact.all_contacts.append(self)
class MilSender:
def send_mail(self, message):
print("Sending mail to " + self.email)
class EmailableContact(Contact, MilSender):
pass
e = EmailableContact("John Smith", "j@qq.com")
Contact.all_contacts
e.send_mail("Hello, test e-mail here.")
参考:本文参考学习《Python3 Object Oriented Programming》,根据自己理解改编,Dusty Phillips 著
标签:sage nbsp 技术 多个 分享图片 功能 [] name cts
原文地址:https://www.cnblogs.com/brightyuxl/p/8824801.html