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 小时前
filetidy 文件整理助手:一键归类 + 规范重命名(Python 零依赖单文件工具)
大数据·开发语言·python·技术美术
gCode Teacher 格码致知10 小时前
Pandas教学-18:number与numeric的区别
python·pandas
梦想不只是梦与想13 小时前
Python 中subprocess 模块:执行外部命令
python·subprocess·调用外部命令
懂点Tech13 小时前
ctfshow MISC入门图片篇(信息附加):misc41解题思路
开发语言·python
catchadmin14 小时前
PHP 8.7 协程新提案 让跨协程代码共享请求身份
开发语言·php
念何架构之路14 小时前
go-grpc设计思想
开发语言·后端·golang
酷炫码神15 小时前
Day 10|Pinia 状态管理:把散落在各组件的数据,收进一个全局仓库
android·开发语言·javascript
Elastic 中国社区官方博客16 小时前
我们如何通过 70 多个拉取请求,将 OpenTelemetry Java agent 迁移到 invokedynamic
java·大数据·开发语言·elasticsearch·搜索引擎·全文检索·es
tyn18816 小时前
记录本地安装nacos服务的方法及异常
java·开发语言
步行cgn17 小时前
Spring MVC 视图机制的核心接口与类
java·开发语言·后端·spring·mvc