Python钉钉提醒
来自CloudWiki
代码
import requests import json class DingTalk_Base: def __init__(self): self.__headers = {'Content-Type': 'application/json;charset=utf-8'} self.url = '' def send_msg(self,text): json_text = { "msgtype": "text", "text": { "content": text }, "at": { "atMobiles": [ "" ], "isAtAll": False } } return requests.post(self.url, json.dumps(json_text), headers=self.__headers).content class DingTalk_Disaster(DingTalk_Base): def __init__(self): super().__init__() # 填写机器人的url self.url = 'https://oapi.dingtalk.com/robot/send?access_token=60bd4b5e21d82db59a36c2e9633aa251e57a9246abc00f6f1eca67e6d1f322d2' if __name__ == '__main__': ding = DingTalk_Disaster() ding.send_msg('马老师好,1号服务器异常,请处理')