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)
相关推荐
m0_746752301 小时前
c++怎么利用std--variant处理多种二进制子协议包的自动分支解析【进阶】
jvm·数据库·python
m0_734949798 小时前
MySQL如何配置定时清理过期备份文件_find命令与保留周期策略
jvm·数据库·python
t***5448 小时前
Clang 编译器在 Orwell Dev-C++ 中的局限性
开发语言·c++
m0_514520578 小时前
MySQL索引优化后性能没提升_通过EXPLAIN查看索引命中率
jvm·数据库·python
H Journey9 小时前
Python 国内pip install 安装缓慢
python·pip·install 加速
oy_mail9 小时前
QoS质量配置
开发语言·智能路由器·php
oyzz1209 小时前
PHP操作redis
开发语言·redis·php
nashane9 小时前
HarmonyOS 6学习:网络能力变化监听与智能提示——告别流量偷跑,打造贴心网络感知应用
开发语言·php·harmony app
Polar__Star10 小时前
如何在 AWS Lambda 中正确使用临时凭证生成 S3 预签名 URL
jvm·数据库·python
凌波粒10 小时前
Java 8 “新”特性详解:Lambda、函数式接口、Stream、Optional 与方法引用
java·开发语言·idea