# coding=utf-8
from abc import ABC, abstractmethod
class People(ABC):
@abstractmethod
def walk(self):
raise Exception
@abstractmethod
def eat(self):
raise Exception
def dance(self):
print('People can dance')
# p = People() # TypeError: Can't instantiate abstract class People with abstract methods eat, walk
class Student(People):
'''
没有实现eat方法: TypeError: Can't instantiate abstract class Student with abstract method eat
'''
def walk(self):
print("I am a student and I can walk")
def eat(self):
print("I am a student and I can eat")
s = Student()
s.walk()
s.dance()