多继承 当父类有重名的属性时 ,嫡长子(最左边的类中的属性)存在
class Phone: IMEI=2020001 producer="apple" def call_by_4g(self): print("4g通话") class NFCReader: nfc_type="第五代" producer="apple" def read_card(self): print("读取NFC卡") def write_card(self): print("写nfc卡") class RemoteControl: rc_type="红外遥控" def control(self): print("红外遥控开启") class MyPhone(Phone,NFCReader,RemoteControl): pass #实例化某个对象 phone1=MyPhone() print(phone1.producer) phone1.write_card() phone1.control() ''' apple 写nfc卡 红外遥控开启 '''
浙公网安备 33010602011771号