python企业微信小程序发送信息

python企业微信小程序发送信息

在使用下面代码之前先配置webhook

教程如下:

https://www.bilibili.com/video/BV1oH4y1S7pN/?vd_source=bee29ac3f59b719e046019f637738769

然后使用如下代码就可以发消息了:

代码如下:

python 复制代码
#coding=gbk
import requests
def send(message:str):
    url = "机器人webhook地址"
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "msgtype": "text",
        "text": {
            "content": message,
            "mentioned_list": ["@all"]
        }
    }
    response = requests.post(url, headers=headers, json=data)
    records = response.json()
    return records
def sendAll(message:str):
    url = "机器人webhook地址"
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "msgtype": "text",
        "text": {
            "content": message,
            "mentioned_list": ["@all"]
        }
    }
    response = requests.post(url, headers=headers, json=data)
    records = response.json()
    return records


def test(stz):
    send(stz)

stz="测试程序"
test(stz)
相关推荐
阳光开朗男孩6 分钟前
Pytorch的安装与配置
人工智能·pytorch·python
等一朵映山红9 分钟前
动态图 vs 静态图:PyTorch 与 TensorFlow 架构底层对比
人工智能·pytorch·python
卷无止境34 分钟前
Python 依赖管理这件事,到底该看哪个文件
后端·python
在世修行41 分钟前
从零打造 C# 工业视觉检测系统(十一):Task 异步编程与实时性保障
开发语言·c#·task异步
卷无止境44 分钟前
FastAPI 缓存方案全解析:从内存到分布式的工程实践
后端·python
烟漠河洛44 分钟前
一条走廊,两张地图
python
苏灿烤鱼1 小时前
GitHub #2 拆解|仅 +59,代码知识图谱为什么仍值得关注?
python·agent·mcp
讲温控就好了1 小时前
数据中心热密度飙升下的超精密温控应对策略
人工智能·python
金融小师妹8 小时前
多因子智能推演:油价回落6%与黄金震荡上行的关联解析——AI预测框架
大数据·python·深度学习