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)
相关推荐
sunly_7 小时前
Go 切片详解
开发语言·oracle·golang
富贵儿9987 小时前
NL2SQL 实践手记 10:从命令行到网页查询——把整个系列串起来
数据库·python·sql·ai·自然语言处理·langchain
fengkai45457 小时前
Python对接LangChain智能体开发(Tool工具调用与 Agent智能体)
运维·开发语言·python·langchain·llm·ai agent·tool
小白的高手之路7 小时前
【LeetCode 热题 100】560. 和为 K 的子数组|前缀和、哈希表(Python)
数据结构·笔记·python·算法·leetcode·力扣·散列表
专注仿真8 小时前
仿真智能体训练(评估篇):鲁棒性/泛化测试算法详解与实战
人工智能·python·算法·afsim智能体训练·评估算法·鲁棒性算法·泛化测试算法
随流寻影8 小时前
利用 C++ 实现二叉搜索树的增删查
开发语言·c++
SummerJokes8 小时前
Java 集合 List 全套实验|从基础增删改查到实体类存储
java·python·list
总要学点什么9 小时前
第128篇:镜头光晕与高光——把逆光太阳晕成会躲山的光斑
开发语言·javascript·数码相机·microsoft·材质·cesium
Escalating_xu9 小时前
【COZE实战】插件与知识库(三):让智能体会查资料,也会使用工具
开发语言·网络·人工智能·ai
车软学堂9 小时前
Docker在隔离什么:namespace、cgroup、chroot三道墙
linux·python·docker·容器·车载系统·汽车·测试用例