Python defines interface inheritance class invalid syntax solution

class s_all(metaclass=abc.ABCMeta):
    #python2.7 use this method to define interface inheritance
    # __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def read(self):
        pass
pyhton2.7 will report an error, this method is used for python3+ 

pyhton2.7 application method definition
class s_all():
    #python2.7 use this method to define interface inheritance
    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def read(self):
        pass

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324971689&siteId=291194637