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)
相关推荐
饮长安千年月7 分钟前
玄机-第八章 内存马分析-java03-fastjson
开发语言·python·安全·web安全·网络安全·应急响应
天天爱吃肉821812 分钟前
新能源汽车动力系统在环(HIL)半实物仿真测试台架深度解析
人工智能·python·嵌入式硬件·汽车
卡次卡次127 分钟前
注意点:挂载与插硬盘,容器挂载实现持久化存储
python
2401_8414956430 分钟前
【LeetCode刷题】找到字符串中所有字母异位词
数据结构·python·算法·leetcode·数组·滑动窗口·找到字符串中所有字母异位词
MediaTea1 小时前
Python 第三方库:OpenPyXL(Excel 文件读写与操作)
开发语言·python·excel
点云SLAM1 小时前
C++ 中dynamic_cast使用详解和实战示例
开发语言·c++·类型转换·dynamic_cast·c++多态·c++继承
CodeByV1 小时前
【C++】C++11:右值引用和移动语义
开发语言·c++
一水鉴天1 小时前
整体设计 全面梳理复盘 之37 元级自动化引擎三体项目(Designer/Master/Transformer)划分确定 + 自用规划工具(增强版)
开发语言·算法·transformer·公共逻辑
自学互联网1 小时前
python爬虫入门案例day05:Pexels
开发语言·爬虫·python
头发还没掉光光2 小时前
C/C++类型转换
c语言·开发语言·c++