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)
相关推荐
AI人工智能+电脑小能手5 分钟前
【大白话说Java面试题】【Java基础篇】第9题:HashMap根据key查询元素的时间复杂度是多少
java·开发语言·数据结构·后端·面试·哈希算法·哈希表
HHHHH1010HHHHH6 分钟前
JavaScript中利用IIFE创建私有命名空间的经典方案
jvm·数据库·python
invicinble9 分钟前
对于java面向对象的知识
java·开发语言
2501_930707789 分钟前
使用C#代码在 PowerPoint 中创建组合图表
开发语言·c#·powerpoint
干洋芋果果11 分钟前
前端学python
开发语言·前端·python
YJlio12 分钟前
1 1.2 Windows 账户的分类:管理员 / 标准 / 来宾 + 微软账户 vs 本地账户
人工智能·python·microsoft·ai·chatgpt·openai·agent
FOREVER-Q12 分钟前
基于 Vite 的前端 SDK 工程化设计与模块化构建实践
开发语言·前端·javascript
invicinble13 分钟前
java面向对象的学习主线
java·开发语言·学习
SDAU200519 分钟前
Arduino编程CH552
c语言·开发语言·单片机
篮子里的玫瑰19 分钟前
Python与网络爬虫——列表与元组
开发语言·爬虫·python