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)
相关推荐
用户912940468484211 分钟前
Codex 从零到能交付(19):让 Codex 做代码审查:发现问题后怎样验证
python
小白勇闯网安圈38 分钟前
day_2
python
山楂树の39 分钟前
Java 泛型:泛型类、泛型方法、泛型接口与通配符
java·开发语言·笔记
叮当小飞鱼44 分钟前
RAG幻觉
python
利威尔xu1 小时前
2026-11-18-Go接口幂等设计实战
开发语言·后端·golang
赵大仁1 小时前
Agent 工具调用可靠性:超时、重试、幂等与人工确认怎么设计
python·agent·幂等·工具调用·人工确认
eggwyw2 小时前
linux下的C\C++多进程多线程编程实例详解
开发语言·c++
布莱克6052 小时前
Swift 枚举详解:从基础语法到关联值与模式匹配
开发语言·ios·swift·枚举
__underline__2 小时前
冷门Python知识点007篇:list[int]不是类,为什么能当基类?
后端·python
Dmz丶2 小时前
前端转 AI 100 天 Day 49:文档切分——RAG 效果的隐形开关
python