# -*- coding: utf-8 -*-
import requests,json
#消息内容,url地址
def dingtalk(msg,webhook):
headers = {'Content-Type': 'application/json; charset=utf-8'}
data = {'msgtype': 'text', 'text': {'content': msg}, 'at': {'atMobiles': [], 'isAtAll': False}}
post_data = json.dumps(data)
response = requests.post(webhook, headers=headers, data=post_data)
return response.text
webhook = 'https://oapi.dingtalk.com/robot/send?access_token=aaa02da492d2b30f1955f1cecffca296dc9a1c4ba1c872b9bc9b7fdbfa7992f6'
dingtalk("msg test",webhook)
![](https://img.haomeiwen.com/i5707419/4561571d50632b43.png)
image.png
![](https://img.haomeiwen.com/i5707419/4e2c3163e661a4df.png)
image.png
网友评论