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)
相关推荐
zjy2777711 分钟前
c++如何实现日志文件的异步落盘功能_基于无锁队列方案【附代码】
jvm·数据库·python
Irene199118 分钟前
PyCharm 大数据开发快速上手指南(类比 VSCode 、Oracle SQL Developer)
python
wang3zc23 分钟前
JavaScript中函数声明位置对解析器预编译的影响
jvm·数据库·python
小白学大数据25 分钟前
JS 混淆加密下的 Python 爬虫解决方案
javascript·爬虫·python
yexuhgu1 小时前
C#怎么使用Tuple元组返回多个值_C#如何简化方法返回值【基础】
jvm·数据库·python
加号31 小时前
【Qt】 应用程序发布:依赖库拷贝与部署指南
开发语言·qt
lulu12165440781 小时前
JetBrains IDE 终极AI编程方案:CC GUI插件让Claude Code和Codex丝滑运行
java·ide·人工智能·python·ai编程
qq_414256572 小时前
JavaScript中类继承中super关键字的调用执行逻辑
jvm·数据库·python
('-')2 小时前
八股复习2:Java Array list和Linked list
java·开发语言
tanis_20772 小时前
MinerU2.5-Pro 中文 PDF 识别准确率全解:OmniDocBench v1.6 权威基准数据
人工智能·python·pdf