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)
相关推荐
yugi9878385 分钟前
MATLAB的多层感知器(MLP)与极限学习机(ELM)实现
开发语言·matlab
星空椰25 分钟前
快速掌握FastAPI:高效构建Web API
python·fastapi
塔尖尖儿25 分钟前
Python中range()到底是什么演示
python
Never_Satisfied33 分钟前
C#获取汉字拼音字母方法总结
开发语言·c#
zh_xuan1 小时前
kotlin 密封类
开发语言·kotlin
码小猿的CPP工坊1 小时前
C++软件开发之内存泄漏闭坑方法
开发语言·c++
Ethan-D1 小时前
#每日一题19 回溯 + 全排列思想
java·开发语言·python·算法·leetcode
满栀5851 小时前
分页插件制作
开发语言·前端·javascript·jquery
froginwe111 小时前
C 标准库 - <stdio.h>
开发语言