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)
相关推荐
zhanghaha131410 分钟前
Python语言基础:4_数据类型转换
java·前端·python
larance29 分钟前
机器学习特征预处理之标准化/归一化
开发语言·python·机器学习
tokenova32 分钟前
Python 多模型统一调用封装类,一套代码兼容 GPT/Claude/Grok
python
农村小镇哥1 小时前
C#中的字符串格式化
服务器·开发语言·c#
Patrick在香港1 小时前
Python实战:用数据分析拆解一场AI大会——WAIC 2026参展企业画像、议题演变与城市格局
人工智能·python·数据挖掘·数据分析·ai编程
Android洋芋2 小时前
AI辅助C盘清理
c语言·开发语言·人工智能·ai辅助c盘清理
小猴子爱上树2 小时前
TikTok Shop视频自动翻译工具实战教程
人工智能·python·音视频·机器翻译
humbinal3 小时前
同时支持 gui & cli 的 parquet 文件查看工具,高性能小清新!
hive·python·rust·spark·开源·github·parquet
90后的晨仔3 小时前
Python 开发完全指南:从入门到工程化落地
python
灯澜忆梦3 小时前
Go 语言 _JSON---序列化与反序列化
开发语言·golang·json