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)
相关推荐
平常心cyk4 分钟前
Python基础快速复习——函数的多种传参方式
python
hashiqimiya11 分钟前
微信小程序--动态切换登录注册标签页
微信小程序·小程序
lanboAI11 分钟前
基于卷积神经网络的舌苔诊断系统,resnet50,alexnet, shufflenet模型【pytorch框架+python源码】
pytorch·python·cnn
计算机安禾12 分钟前
【数据结构与算法】第10篇:项目实战:学生信息管理系统(线性表版)
开发语言·数据结构·算法·visual studio
QWsin19 分钟前
【Pydantic】Pydantic 是什么?
python
WeeJot嵌入式20 分钟前
爬虫对抗:ZLibrary反爬机制实战分析
爬虫·python·网络安全·playwright·反爬机制
hashiqimiya20 分钟前
微信小程序--获取验证码设计倒计时灰白色
微信小程序·小程序
MyBFuture20 分钟前
Halcon模板匹配核心技术解析大全
开发语言·人工智能·计算机视觉·halcon·机器视觉
精神小伙就是猛26 分钟前
使用go-zero快速搭建一个微服务(一)
开发语言·后端·微服务·golang
不会聊天真君64728 分钟前
基础语法·下(golang笔记第三期)
开发语言·笔记·golang