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)
相关推荐
李白的天不白13 分钟前
python下载脚本
python
2501_9095091015 分钟前
DAY 45
python
郝学胜_神的一滴31 分钟前
Python 高级编程 027:四大推导式全攻略
python·pycharm
菜冻鱼41 分钟前
Python-sklearn-特征工程
开发语言·人工智能·python·机器学习·numpy·matplotlib·sklearn
mit6.8241 小时前
archived
后端·python·flask
船长@1 小时前
FastAPI 快速上手:从零基础到实操入门
python·ai·fastapi
吴声子夜歌1 小时前
正则指引——PHP
开发语言·正则表达式·php
Claire_881 小时前
企业文件管理系统选型技术框架与主流产品对比分析
开发语言·php
(Charon)1 小时前
【C++】:使用 mutex + deque 实现一个简单的 LockedQueue
开发语言·c++
我要两颗404西柚1 小时前
2【python】:常用关键字,函数,方法
python