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)
相关推荐
一叶之秋14121 分钟前
类型驱动:解锁Qt模板的渲染潜能
开发语言·qt
青瓷程序设计2 小时前
基于YOLO的火灾烟雾检测系统~Python+目标检测+算法模型+2026原创
python·yolo·目标检测
立莹Sir2 小时前
Spring Bean 生命周期详解
java·python·spring
JHC0000008 小时前
基于Ollama,Milvus构建的建议知识检索系统
人工智能·python·milvus
mOok ONSC8 小时前
SpringBoot项目中读取resource目录下的文件(六种方法)
spring boot·python·pycharm
ZPC82108 小时前
如何创建一个单例类 (Singleton)
开发语言·前端·人工智能
超绝振刀怪8 小时前
【C++多态】
开发语言·c++
workflower9 小时前
AI制造-推荐初始步骤
java·开发语言·人工智能·软件工程·制造·需求分析·软件需求
GIS兵墩墩9 小时前
postgis--PostgreSQL16及其plpython3u扩展
python·postgis
new Object ~9 小时前
LangChain的短期记忆存储实现
python·langchain