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)
相关推荐
琅琊榜首20204 分钟前
AI+Python实操指南:用编程赋能高质量网络小说创作
开发语言·人工智能·python
Faker66363aaa5 分钟前
基于YOLO13-C3k2-Strip的神经退行性疾病MRI影像自动识别
python
tbRNA7 分钟前
C++ string类
开发语言·c++
ccLianLian8 分钟前
算法基础·C++常用操作
开发语言·数据结构·c++
草莓熊Lotso12 分钟前
Linux 程序地址空间深度解析:虚拟地址背后的真相
java·linux·运维·服务器·开发语言·c++·人工智能
郝学胜-神的一滴14 分钟前
使用Linux命名管道(FIFO)实现无血缘关系进程间通信
linux·服务器·开发语言·c++·程序人生
HAPPY酷17 分钟前
std::pair` 与 `std::map` 基础
开发语言·c++·算法
懒神降世17 分钟前
基于iVentoy的PXE服务器的部署实战指南
运维·服务器·开发语言·云原生·vmware·openeuler·iventoy
山东布谷网络科技23 分钟前
对标Yalla和Chamet:海外直播语聊APP中多人派对房的关键技术细节
java·开发语言·人工智能·php·语音识别·软件需求·海外电商系统开发
Dxy123931021629 分钟前
Python 将 JSON 字符串转换为字典
前端·python·json