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)
相关推荐
FITA阿泽要努力1 分钟前
/goal 命令:给 Agent 设定目标
服务器·人工智能·python·agent
zhangx1234_4 分钟前
javaEE 多线程4
java·开发语言
大陈子编程11 分钟前
C++ 背包九讲:从入门到精通的动态规划专题
开发语言·c++·动态规划
qq_4017004118 分钟前
Qt 组播(Multicast)实战详解
开发语言·qt
小小张说故事22 分钟前
Python 的 dict 为什么插入顺序不会乱?拆开 3.6 的紧凑布局:indices 与 entries 两张表
python
椰萝Yerosius23 分钟前
严正声明 | 博主已正式放弃CSDN作为博客平台
python
Sapphire~31 分钟前
odoo-095 视图的重写规则(全部重写还是部分改写)
开发语言·javascript·ecmascript
利威尔xu32 分钟前
Go GMP 调度器 10 个高频追问:3 个线上故障让 P99 从 80ms 飙到 2s、10 万 goroutine 泄漏
开发语言·后端·面试·性能优化·golang
中电金信39 分钟前
从业务调优到分层缓存:DeepSeek V4 Flash的PPU实践
java·开发语言
肖永威39 分钟前
python版微电网仿真工具的前端托管选型:从http.server到FastAPI StaticFiles
前端·python·http·fastapi