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)
相关推荐
yong999012 小时前
基于Qt的文件传输系统
开发语言·qt
yuan1999712 小时前
基于 MATLAB PSO 工具箱的函数寻优算法
开发语言·算法·matlab
汤米粥12 小时前
python学习——核心语法三
java·python·学习
handler0112 小时前
【C++】二叉搜索树详解及其模拟实现(代码)
开发语言·c++·算法·c··二叉搜索树·搜索树
luj_176812 小时前
残熵算法的稳健防灾逻辑
c语言·开发语言·c++·经验分享·算法
七老板的blog12 小时前
从持久化任务到多 Agent 协作
python·学习·ai
一只鹿鹿鹿13 小时前
信息化项目管理规范(参考Word文件)
java·大数据·运维·开发语言·数据库
XGeFei13 小时前
python中子线程与主线程的关系
开发语言·python
Chase_______13 小时前
【Java杂项】final 关键字详解:变量、方法、类限制与引用可变性
java·开发语言·python
ruxingli13 小时前
Golang iota详解
开发语言·后端·golang