Python推送钉钉消息

钉钉消息推送

#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import json

def dingmessage():
#钉钉机器人Token
    webhook = "token"
    header = {
        "Content-Type": "application/json",
        "Charset": "UTF-8"
}
    tex = "该吃饭了!"
    message ={

        "msgtype": "text",
        "text": {
            "content": tex
        },
        "at": {

            "isAtAll": True
        }

    }
    message_json = json.dumps(message)
    info = requests.post(url=webhook,data=message_json,headers=header)
    print(info.text)

if __name__=="__main__":
    dingmessage()

猜你喜欢

转载自blog.csdn.net/qq_42979842/article/details/107824907