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)
相关推荐
IT=>小脑虎8 分钟前
Python爬虫零基础学习知识点详解【基础版】
爬虫·python·学习
比奇堡派星星28 分钟前
Linux OOM Killer
linux·开发语言·arm开发·驱动开发
hqwest39 分钟前
码上通QT实战11--监控页面03-绘制湿度盘和亮度盘
开发语言·qt·绘图·自定义组件·部件·qpainter·温度盘
张心独酌43 分钟前
Rust开发案例库-静态服务器
服务器·开发语言·rust
做萤石二次开发的哈哈1 小时前
萤石开放平台 萤石可编程设备 | 设备 Python SDK 使用说明
开发语言·网络·python·php·萤石云·萤石
子有内涵1 小时前
【C++】红黑树实现
开发语言
降临-max1 小时前
JavaWeb企业级开发---Mybatis
java·开发语言·笔记·学习·mybatis
bing.shao1 小时前
golang 做AI任务链的优势和场景
开发语言·人工智能·golang
知乎的哥廷根数学学派1 小时前
基于多物理约束融合与故障特征频率建模的滚动轴承智能退化趋势分析(Pytorch)
人工智能·pytorch·python·深度学习·算法·机器学习
我是一只小青蛙8881 小时前
位图与布隆过滤器:高效数据结构解析
开发语言·c++·算法