继承
单继承
class Phone:
id = None
producer = "HW"
def call_4g(self):
print("4g通话")
class Phone2023(Phone):
face_id = "1001"
def call_45g(self):
print("4.5g")
phone = Phone2023()
print(phone.producer)
phone.call_4g()
phone.call_45g()
多继承
class Phone:
id = None
producer = "HW"
def call_4g(self):
print("4g通话")
class Phone2023(Phone):
face_id = "1001"
def call_45g(self):
print("4.5g")
class NFCreader:
nfc_type = "瑞克5代"
producer = "XM"
def read_card(self):
print("read")
def write_card(self):
print("write")
class R_laser:
rc_type = "芝士海豹"
def control(self):
print("红外,启动")
class my_Phone(Phone, R_laser, NFCreader):
pass
phone = my_Phone()
phone.call_4g()
phone.read_card()
phone.write_card()
phone.control()
print(phone.producer)