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)
相关推荐
c238567 分钟前
C/C++每日一练21
c语言·开发语言·c++
小猴子爱上树8 分钟前
跨马翻译:批量图片翻译与视频字幕工具,跨境电商高效助手
python·音视频
qq_401700418 分钟前
Qt Modbus协议0x00
开发语言·qt
yushikong10 分钟前
关于rust开发ch32x033f8p6的一些记录
开发语言·后端·rust
2501_9095091010 分钟前
DAY 42
python
数字化转型分享点滴13 分钟前
聚焦机加工MES系统:四化信息科技以服务数字化转型
大数据·人工智能·python·科技
吴声子夜歌22 分钟前
正则表达式——环视
开发语言·正则表达式
weixin_BYSJ198725 分钟前
springboot医疗信息管理系统---附源码17465
java·javascript·spring boot·python·django·flask·php
zhongjunyao39 分钟前
Spec-Driven Development (SDD): The Definitive 2026 Guide
javascript·spring boot·python·eclipse·代理模式
福大大架构师每日一题40 分钟前
agno v2.8.7 发布:顾问模型、精准路线、调度能力全面升级,10项关键修复一次看懂
java·开发语言·数据库