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)
相关推荐
0xDevNull4 小时前
Java反射机制深度解析:从原理到实战
java·开发语言·后端
小小亮014 小时前
Next.js基础
开发语言·前端·javascript
ALex_zry4 小时前
C++网络编程心跳机制与连接保活:长连接稳定性保障
开发语言·网络·c++
Amumu121385 小时前
Js:正则表达式(二)
开发语言·javascript·正则表达式
Sgf2275 小时前
ES8(ES2017)新特性完整指南
开发语言·javascript·ecmascript
IAUTOMOBILE5 小时前
Python 流程控制与函数定义:从调试现场到工程实践
java·前端·python
好大哥呀5 小时前
C++ Web 编程
开发语言·前端·c++
ID_180079054735 小时前
小红书笔记评论 API,Python 调用示例与完整 JSON 返回参考
java·开发语言
南境十里·墨染春水7 小时前
C++ 笔记 友元(面向对象)
开发语言·c++·笔记
TT_44197 小时前
python程序实现图片截图溯源功能
开发语言·python