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)
相关推荐
傻啦嘿哟几秒前
一篇文章讲清楚Python的变量作用域
开发语言·python
devilnumber几秒前
Java 二分查找(二分算法)详解 + 实战运用 + 核心坑点
java·开发语言·算法
装不满的克莱因瓶3 分钟前
学习 LPRNet 框架——轻量级车牌识别网络从结构到工程落地
人工智能·python·深度学习·机器学习·ai
dust_and_stars4 分钟前
Streamlit vs Gradio 完整对比
服务器·python
ch.ju6 分钟前
Java程序设计(第3版)第四章——重载和覆盖的区别
java·开发语言
AI科技星11 分钟前
第四卷:橡皮泥江湖(拓扑学)
c语言·开发语言·网络·量子计算·agi·拓扑学
浮尘笔记12 分钟前
Go实现大文件异步流式采集引擎
开发语言·后端·golang
winfredzhang12 分钟前
Python + wxPython + SQLite 实战:开发一个本地 Python 项目一键启动管理工具
python·sqlite·bat·截图·claudecode·codingliteplan
yugi98783815 分钟前
基于C#实现数字识别率的OCR方案
开发语言·c#·ocr
星越华夏18 分钟前
python中四种获取文件后缀名的方法
开发语言·python