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)
相关推荐
Generalzy几秒前
像 gofmt 一样格式化 Python:Black、Ruff、YAPF、autopep8 谁才是 2026 年的首选?
开发语言·python
计算机源码社3 分钟前
【大数据项目实战】基于Python数据挖掘的新能源车充电行为关联风险分析研究-基于Hadoop+Spark的电动汽车故障多维数据可视化
大数据·hadoop·python·数据挖掘·spark·毕业设计·课程设计
朝朝辞暮i5 分钟前
C++第一课
开发语言·c++·算法
LlmCraft|大模型工程实践6 分钟前
NLP预处理Python内置函数_02_分词辅助与过滤筛选
python·自然语言处理·easyui
某林2129 分钟前
机器人重启失联:DDS 发现机制与传输层静默故障
人工智能·python·机器人·硬件架构·ros2
李少兄15 分钟前
JavaScript 对象完全指南
开发语言·javascript·ecmascript
张小姐的猫17 分钟前
【AI大模型接入SDK】 —— Ollama本地接入Deepseek
java·linux·开发语言·网络·c++·人工智能
Nuanyt20 分钟前
JUC常见核心知识梳理01 线程 并发 JMM volatile 管程 锁 synchronized
java·开发语言·网络·jvm
adaierya28 分钟前
用 AI 解决音频转换编程问题
开发语言·人工智能·python·分类·ai编程
ai小陈29 分钟前
PyTorch梯度累积与裁剪实战:小显存也能稳定训练大批次
人工智能·pytorch·python·深度学习·ai·gpu算力