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)
相关推荐
Geek-Chow13 分钟前
Mobile App Certificate Pinning: Underlying Principle and a Swift Example
开发语言·ios·swift·安全架构
码云骑士17 分钟前
61-LangChain-vs-LlamaIndex-选型对比-功能矩阵-混用实践
python·线性代数·矩阵·langchain
阿豪只会阿巴22 分钟前
两小时快速入门 FastAPI--第一回
开发语言·python·fastapi
Hesionberger31 分钟前
动态规划与二分法破解最长递增子序列
java·数据结构·python·算法·leetcode
JustNow_Man34 分钟前
【Claude Code】 中给 Python + XML 项目建立可靠验证体系
xml·linux·python
你怎么知道我是队长37 分钟前
JavaScript 事件介绍
开发语言·前端·javascript
薛定猫AI40 分钟前
【技术干货】多模型AI编程代理实战:用Python统一接入Claude Opus 4.8
人工智能·python·ai编程
CodeStats42 分钟前
【Linux IO】从文件描述符到硬件中断:Linux IO 系统底层完全拆解
java·linux·开发语言·io·socket
着迷不白1 小时前
Linux系统故障修复、日志管理与安全加固实战指南
开发语言·php
贺国亚1 小时前
A2A协议与Agent互操作-Task生命周期
开发语言·qt