#python没有类似于java和C#的接口类(interface),需要使用抽象类 和抽象方法来实现接口功能

 

 

#!/usr/bin/env python
#_*_ coding:utf-8 _*_

 

from abc import ABCMeta
from abc import abstractmethod


class Alert:
__metaclass__= ABCMeta

@abstractmethod
def send(self):
pass

#继承抽象类
class Weixin(Alert):
def __init__(self):
print "初始化微信告警"

#必须定义抽象方法
def send(self):
print "发送微信告警"


W = Weixin()
W.send()

相关文章:

  • 2019-05-21
  • 2021-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-11-28
  • 2021-12-05
  • 2022-01-09
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-08-30
  • 2021-10-19
  • 2021-07-29
相关资源
相似解决方案