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)
相关推荐
2401_8318249611 分钟前
代码性能剖析工具
开发语言·c++·算法
Oueii19 分钟前
Django全栈开发入门:构建一个博客系统
jvm·数据库·python
是wzoi的一名用户啊~24 分钟前
【C++小游戏】2048
开发语言·c++
2401_831824961 小时前
使用Fabric自动化你的部署流程
jvm·数据库·python
Sunshine for you1 小时前
C++中的职责链模式实战
开发语言·c++·算法
njidf1 小时前
Python日志记录(Logging)最佳实践
jvm·数据库·python
@我漫长的孤独流浪1 小时前
Python编程核心知识点速览
开发语言·数据库·python
宇擎智脑科技1 小时前
A2A Python SDK 源码架构解读:一个请求是如何被处理的
人工智能·python·架构·a2a
2401_851272991 小时前
实战:用Python分析某电商销售数据
jvm·数据库·python
vx_biyesheji00011 小时前
Python 全国城市租房洞察系统 Django框架 Requests爬虫 可视化 房子 房源 大数据 大模型 计算机毕业设计源码(建议收藏)✅
爬虫·python·机器学习·django·flask·课程设计·旅游