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)
相关推荐
wuyk5556 分钟前
从零吃透Modbus通信|第3章:STM32 Modbus RTU主机
服务器·开发语言·网络·数据结构·stm32·单片机·嵌入式硬件
绘梨衣54713 分钟前
异步任务队列-学习2
爬虫·python·学习·任务队列
用户8356290780511 小时前
使用 Python 在 Excel 中插入 OLE 对象
后端·python
one3121 小时前
高精度MEMS电容式倾角传感器:原理、结构与Python三维可视化
开发语言·python
程序员小八7771 小时前
Go 语言特性
开发语言·后端·golang
深蓝海拓2 小时前
基于QtPy (PySide6) 的PLC-HMI工程实战记录(七)创建适合HMI项目的数字输入/显示类部件
python
INGNIGHT2 小时前
1908 · 布尔表达式求值(stack单调栈&dfs)
开发语言·c++·算法
MartinYeung52 小时前
[论文学习]MPIB:医疗提示注入基准——针对LLM临床安全性的系统性评估
人工智能·python·学习
এ慕ོ冬℘゜2 小时前
深入理解浏览器全屏 API:从 requestFullscreen 到全屏实战
开发语言·html