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
Wang's Blog1 小时前
Java 项目实战:交友项目 - 用户体系集成总结
java·开发语言·交友
中科三方2 小时前
IPv6检测常见问题:AAAA记录检测不通过是什么原因?
开发语言·php
卡提西亚2 小时前
FastAPI基础入门
python·fastapi
fanruitian2 小时前
python 机器学习 ML LinearRegression KNN KMeans
python·机器学习·kmeans
鱼宵2 小时前
取集合第一个元素,Java 为什么要写三种写法?
java·windows·python·java21
卷无止境2 小时前
给AI装上一双眼睛:快速构建代码验证器的思路与落地方案
后端·python
沫璃染墨2 小时前
从零入门计算机网络系列(十一):HTTP协议进阶——从重定向原理到GET/POST与Fiddler抓包
linux·服务器·开发语言·网络·c++·tcp/ip·html
维克兜率天3 小时前
【维克】指数调整:哪些股票会被“强制买入“?
人工智能·python·算法
刚入门的大一新生3 小时前
Linux-线程互斥
java·开发语言