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)
相关推荐
超神熊猫9 分钟前
🧀🧀🧀前端仔如何快速上手python
前端·python
卷无止境22 分钟前
Flet 完全教程:用纯 Python 构建跨平台应用
前端·python
北冥you鱼28 分钟前
Go语言与默克尔树:区块链数据完整性的基石
开发语言·golang·区块链
量化吞吐机32 分钟前
2026年AI量化工具评估,先分开学习开发和验证
人工智能·python
库克克37 分钟前
【C++】类和对象--this指针详解
java·开发语言·c++
JackieZhengChina1 小时前
image-viewer-js 开源图片查看插件完整教程
开发语言·javascript·开源
光影少年1 小时前
react的View/Text/Image/ScrollView 常用组件注意事项
开发语言·前端·javascript·react.js·前端框架
白帽小阳1 小时前
Typora插件开发指南:打造专属IDE式写作环境
c语言·网络·python·网络安全·github·pygame·护网行动
满怀冰雪1 小时前
02-安装 PaddlePaddle:CPU、GPU 与环境检查入门
人工智能·python·paddlepaddle
hanxiuchao2 小时前
告别客户端臃肿!网页端 M3U8 播放调试方案,适配全办公场景
运维·python·django·m3u8·m3u8播放