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)
相关推荐
默归1 分钟前
Java云原生时代面临的挑战与变革
java·开发语言·云原生
南境十里·墨染春水6 分钟前
C++传记 this指针 及区分静态非静态成员(面向对象)
开发语言·jvm·c++·笔记
揽月凡尘7 分钟前
基于 SWIG 的 C++ Embind 绑定自动化技术说明
开发语言·c++·自动化
源码之家11 分钟前
计算机毕业设计:基于Python的美食菜谱数据分析可视化系统 Django框架 爬虫 机器学习 数据分析 可视化 食物 食品 菜谱(建议收藏)✅
爬虫·python·数据分析·django·flask·课程设计·美食
原来是猿14 分钟前
为什么要配置环境变量?
linux·数据库·python
武藤一雄15 分钟前
C# 中精准锁定类型信息指南:typeof vs GetType()
开发语言·windows·c#·.net·.netcore
IAUTOMOBILE16 分钟前
Qt 入门级开发实践:浅析基于 QTtest 项目的 C++ GUI 编程基础
开发语言·c++·qt
剑穗挂着新流苏31216 分钟前
204_从回归到分类:Softmax 回归、损失函数与多分类实战
人工智能·pytorch·python·深度学习
凸头18 分钟前
从聊天机器人到业务执行者:Agentic Orchestration 如何重构 Java 后端体系
java·开发语言·重构
源码之家21 分钟前
计算机毕业设计:基于Python的汽车数据可视化分析系统 Django框架 Scrapy爬虫 可视化 车辆 懂车帝大数据 数据分析 机器学习(建议收藏)✅
python·信息可视化·django·flask·汽车·课程设计·美食