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)
相关推荐
2501_9411114015 小时前
使用Scrapy框架构建分布式爬虫
jvm·数据库·python
今天吃饺子15 小时前
如何用MATLAB调用python实现深度学习?
开发语言·人工智能·python·深度学习·matlab
2501_9411114615 小时前
C++与硬件交互编程
开发语言·c++·算法
萧鼎15 小时前
Python Mahotas 图像处理库:高性能计算机视觉工具
图像处理·python·计算机视觉
破烂pan15 小时前
lmdeploy.pytorch 新模型支持代码修改
python·深度学习·llm·lmdeploy
水木姚姚16 小时前
初识C++
开发语言·c++
麦麦大数据16 小时前
F047 vue3+flask微博舆情推荐可视化问答系统
python·flask·知识图谱·neo4j·推荐算法·舆情分析·舆情监测
权泽谦16 小时前
新世代的 C++:当 ChatGPT 遇上模板元编程
开发语言·c++·chatgpt
MediaTea16 小时前
Python 第三方库:Flask(轻量级 Web 框架)
开发语言·前端·后端·python·flask