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)
相关推荐
码兄科技2 小时前
Java AI智能体开发实战:从零构建智能对话系统指南
java·开发语言·人工智能
Drone_xjw3 小时前
从 GDB 到 CDB:C/C++ 程序调试的两把“手术刀”
c语言·开发语言·c++
SL-staff4 小时前
智慧园区2000+设备统一管理:JVS-IoT如何降低运维成本40%
java·开发语言·物联网·智慧园区·设备管理·运维优化·jvs-iot
聪明的一休丶4 小时前
VLLM v0.24.0 版本深度解析:新引擎、新架构与大规模服务全家桶升级
python·架构·vllm
2zcode5 小时前
基于MATLAB图像处理的饮料瓶灌装液位检测系统设计与实现
开发语言·图像处理·matlab
万亿少女的梦1685 小时前
基于Python的高考志愿填报辅助系统设计与实现
java·spring boot·python·mysql·vue
必须得开心呀6 小时前
QT解决中文乱码问题
开发语言·qt
衍生星球7 小时前
SpringBoot3 + Vue3 + 微信小程序如何学习,以及学哪些技术,组件
sql·微信小程序·uni-app·vue·springboot
闲猫7 小时前
Python FastAPI + SQLAlchemy 入门教程:从零搭建你的第一个 Web 应用
前端·python·fastapi
这不小天嘛7 小时前
JAVA八股——redis篇
java·开发语言·redis