接口继承/ 动态导入模块

 
  
import abc
class All_file(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def read(self):
        pass
    @abc.abstractmethod
    def write(self):
        pass
class Disk(All_file):
    def read(self):
        print('disk read')
    # def write(self):
    #     print('disk write')

m1=Disk()

TypeError: Can't instantiate abstract class Mem with abstract methods write
#  当定义了abc.abstractmethod属性后,衍生类,必须定义此方法



继承:
父类.__init__(self,name,speed,load,power)
# super().__init__(name,speed,load,power)
# super(衍生类,self).__init__(name,speed,load,power)

调用父类的方法:
Vehicle.run(self)
super().run()
module_t=__import__('m1.t')
print(module_t)
module_t.t.test1()

import  importlib
m=importlib.import_module('m1.t')
print(m)
m.test1()
m._test2()



你可能感兴趣的:(Python成长之路)