python 调用钉钉机器人的方法

yipeiwu_com7年前Python基础

以text格式的消息为例:(只需修改content后的内容)

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 调用钉钉机器人的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python IDLE 错误:IDLE''s subprocess didn''t make connection 的解决方案

Python IDLE 错误描述: Subprocess Startup Error IDLE's subprocess didn't make connection. Eithe...

Python3操作SQL Server数据库(实例讲解)

Python3操作SQL Server数据库(实例讲解)

1.前言 前面学完了SQL Server的基本语法,接下来学习如何在程序中使用sql,毕竟不能在程序中使用的话,实用性就不那么大了。 2.最基本的SQL查询语句 python是使用pym...

python排序函数sort()与sorted()的区别

python 中sorted与sort有什么区别 sort(cmp=None, key=None, reverse=False) sorted(iterable, cmp=None, k...

Python使用字典的嵌套功能详解

当需要存储很多同类型的不通过数据时可能需要使用到嵌套,先用一个例子说明嵌套的使用 1、在列表中存储字典 #假设年级里有一群国际化的学生,有黄皮肤的中国人、有白皮肤的美国人也有黑皮肤的...

pytorch:torch.mm()和torch.matmul()的使用

如下所示: torch.mm(mat1, mat2, out=None) → Tensor torch.matmul(mat1, mat2, out=None) → Tensor...