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)
相关推荐
山沐与山4 分钟前
【设计模式】Python责任链模式:从入门到实战
python·设计模式·责任链模式
bjxiaxueliang5 分钟前
一文详解Cpp多线程编程:从传统pthread到现代thread实践指南
java·开发语言·jvm
luoluoal8 分钟前
基于python的图像的信息隐藏技术研究(源码+文档)
python·mysql·django·毕业设计·源码
QQ_43766431410 分钟前
C++11并发编程
开发语言·c++
电商API_1800790524718 分钟前
淘宝商品视频提取API全解析:从授权到落地实战
爬虫·python·信息可视化·数据分析·音视频
leiming623 分钟前
c++ 容器 queue
开发语言·c++
计算机程序设计小李同学26 分钟前
基于 Flask 的养猪场信息模拟系统
后端·python·flask
CSDN_RTKLIB27 分钟前
【类定义系列三】内联函数进阶
开发语言·c++
Iridescent112136 分钟前
Iridescent:Day38
python
熬夜敲代码的小N36 分钟前
2026 职场生存白皮书:Gemini Pro 实战使用指南
人工智能·python·ai·职场和发展