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)
相关推荐
Absurd58724 分钟前
JavaScript中模块化在游戏引擎开发中的资源调度作用
jvm·数据库·python
2301_815279521 小时前
SQL如何利用聚合函数生成业务分析指标_KPI计算基础教程
jvm·数据库·python
qq_330037991 小时前
mysql如何排查Out of memory错误_mysql内存分配调优
jvm·数据库·python
好家伙VCC1 小时前
**发散创新:用Rust实现基于RAFT共识算法的轻量级分布式日志系统**在分布式系统中,**一致性协议**是保障数据可靠
java·分布式·python·rust·共识算法
weixin_458580122 小时前
如何在 Go 中直接将 AST 编译为可执行二进制文件?
jvm·数据库·python
晔子yy2 小时前
【JAVA探索之路】从头开始讲透、实现单例模式
java·开发语言·单例模式
阿正的梦工坊7 小时前
JavaScript 微任务与宏任务完全指南
开发语言·javascript·ecmascript
2301_816660218 小时前
PHP怎么处理Eloquent Attribute Inference属性推断_Laravel从数据自动推导类型【操作】
jvm·数据库·python
第一程序员8 小时前
数据工程 pipelines 实践
python·github
知行合一。。。8 小时前
Python--05--面向对象(属性,方法)
android·开发语言·python