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)
相关推荐
JAVA+C语言3 分钟前
C++ STL map 系列全方位解析
开发语言·c++
福赖4 分钟前
《C#反射机制》
开发语言·c#
进击的小头4 分钟前
第18篇:PID参数整定与裕度优化的现场调试实战
python·算法
向上的车轮16 分钟前
熟悉C#如何转TypeScript?
开发语言·typescript·c#
wumingqilin25 分钟前
QT 防抖和 节流处理
开发语言·qt
Mem0rin25 分钟前
[Java/数据结构]顺序表之ArrayList
java·开发语言·数据结构
毕设源码-赖学姐36 分钟前
【开题答辩全过程】以 居家养老服务微信小程序设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
9稳37 分钟前
基于PLC的生产线自动升降机设计
开发语言·网络·数据库·嵌入式硬件·plc
我是唐青枫44 分钟前
C#.NET ReaderWriterLockSlim 深入解析:读写锁原理、升级锁与使用边界
开发语言·c#·.net