以text格式的消息为例:(只需修改content后的内容)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
Import json
Import requests
url = 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxx'
HEADERS = { "Content-Type" : "application/json;charset=utf-8" }
String_textMsg = { "msgtype" : "text" , "text" :{ "content" : 'kind:%s\naverage:%f\nmedian:%f\nQ10:%f\nQ90:%f' % ( "Trans" ,average,median,Q10,Q90)}}
String_textMsg = json.dumps(String_textMsg)
res = requests.post(url,data = String_textMsg,headers = HEADERS)
print (res.text)
|
以上这篇python 调用钉钉机器人的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/honey_babay/article/details/82871733