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)
相关推荐
呱牛do it2 分钟前
企业级软件研发团队绩效考核系统开发(持续更新 Day 8)
python·fastapi·研发管理
阿kun要赚马内5 分钟前
Python面向对象:@property装饰器
开发语言·前端·python
sunwenjian8866 分钟前
Java进阶--IO流
java·开发语言
wildlily84277 分钟前
C++ Primer 第5版章节题 第十三章(二)
开发语言·c++
测试199811 分钟前
Python+Excel读取和存储测试数据完成接口自动化测试
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
曲幽14 分钟前
FastAPI + Celery 实战:异步任务的坑与解法,我帮你踩了一遍
redis·python·fastapi·web·async·celery·background·task·queue
意法半导体STM3219 分钟前
【官方原创】STM32H7双核芯片通过 STlink连接失败问题分析 LAT1654
开发语言·前端·javascript·stm32·单片机·嵌入式硬件
深蓝海拓22 分钟前
使用@property将类方法包装为属性
开发语言·python
xiaoye-duck35 分钟前
【C++:unordered_set和unordered_map】 深度解析:使用、差异、性能与场景选择
开发语言·c++·stl
zjjsctcdl1 小时前
java与mysql连接 使用mysql-connector-java连接msql
java·开发语言·mysql