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)
相关推荐
Qlittleboy5 分钟前
PHP的接口参数传递的过多,max_input_vars = 5000
开发语言·php
Aurorar0rua6 分钟前
CS50 x 2024 Notes Algorithms - 02
c语言·开发语言·学习方法
en.en..14 分钟前
冒泡排序与选择排序完整对比解析
开发语言·数据结构·算法·c#·排序算法
兰令水20 分钟前
hot100【acm版】【2026.7.18打卡-java版本】
java·开发语言·算法
cui_ruicheng29 分钟前
Python从入门到实战(十三):模块、包与环境管理
开发语言·python
就叫飞六吧43 分钟前
子页面和dialog案例
开发语言·javascript·ecmascript
李宸净1 小时前
Web自动化测试selenium+python
前端·python·selenium
而后笑面对1 小时前
生信bwa算法
python
倒流时光三十年1 小时前
Logback 系列(3):三大核心组件 Logger / Appender / Encoder
java·开发语言·logback
Darkwanderor2 小时前
动、静态库相关内容的详细介绍
linux·c语言·开发语言·c++