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)
相关推荐
Metaphor6924 分钟前
使用 Python 快速在 Word 文档中插入图片
python·word
2601_9668714018 分钟前
Python 爬虫 + 数据挖掘实战:数据抓取与深度挖掘分析全流程
爬虫·python·数据挖掘
青禾83730 分钟前
Linux 系统信息、权限管理与 Python 并发编程(协程与线程)完全指南
linux·python
caimouse36 分钟前
ReactOS 图形系统分析(47):GDI 批处理 — gdibatch.c
c语言·开发语言
曲无忆36 分钟前
密码学三大核心技术解析
python·密码学
qq210846295338 分钟前
在python中什么是 self 和 cls?
开发语言·前端·python
nanawinona1 小时前
2026年手工思路量化后,工具重点会怎样变化
人工智能·python
杨充1 小时前
05.多用组合和少继承
开发语言·bash
今天AI了吗1 小时前
从聊天到委派:AI Agent 如何推进长期任务
数据库·人工智能·python·sql·rust