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)
相关推荐
阿坨23 分钟前
firestart:一行命令启动你的日常应用和网页
python·pypi·cli·click
老歌老听老掉牙33 分钟前
麻花钻切屑形态演变的力学机制与临界条件分析
python·算法·钻头
周杰偷奶茶44 分钟前
【Java】数组的定义和使用(附管理系统实战案例)
java·开发语言
happylifetree1 小时前
Python18(补充):练习
python
橙子圆1231 小时前
JUC之集合类不安全
java·开发语言
阿里嘎多学长1 小时前
2026-09-29 GitHub 热点项目精选
开发语言·程序员·github·代码托管
Bruce_Liuxiaowei1 小时前
网页版 DeepSeek “harness desktop“ WebGL 上下文创建失败排查实录
开发语言·javascript·webgl
weixin_416667962 小时前
银河麒麟V10看门狗试验-1
网络·chrome·python
狗凯之家源码网2 小时前
PHP 用户反馈系统源码深度评测与实战指南
开发语言·php·用户反馈系统
古城小栈2 小时前
Pydantic 从入门到实践全讲解
python