03 对象到底是个啥?
对象到底是个啥?
# 2. 基于面向对象的方式实现上述功能
# 定义类
class MessageInfo:
# 方法
def send_email(to, body):
msg = f'给{to}发送邮件,内容:{body}'
print(msg)
# 方法
def send_dingding(to, body):
msg = f'给{to}发送邮件,内容:{body}'
print(msg)
# 方法
def send_wechat(to, body):
msg = f'给{to}发送邮件,内容:{body}'
print(msg)
# 创建对象
obj = MessageInfo()
# 调用方法
obj.send_email('test@qq.com', '下班了')
obj.send_dingding('test@qq.com', '房价降了')
obj.send_wechat('test@qq.com', '房价降了')