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)
相关推荐
p***s913 分钟前
Windows安装Rust环境(详细教程)
开发语言·windows·rust
卡比巴拉—林20 分钟前
Python print()函数详讲
开发语言·python
奶思图米球28 分钟前
Python多环境管理
开发语言·python
Aerelin31 分钟前
iframe讲解(爬虫playwright的特殊应用)
前端·爬虫·python·html
JienDa32 分钟前
JienDa聊PHP:基于协同架构的PHP主流框架优势整合与劣势补救策略
开发语言·架构·php
i***395835 分钟前
JAVA系统中Spring Boot 应用程序的配置文件:application.yml
java·开发语言·spring boot
时光追逐者44 分钟前
C# 中 ?、??、??=、?: 、?. 、?[] 各种问号的用法和说明
开发语言·c#·.net·.net core
量化Mike1 小时前
【python报错】解决卸载Python时报错问题:No Python installation was detected
开发语言·python
q***01771 小时前
PHP进阶-在Ubuntu上搭建LAMP环境教程
开发语言·ubuntu·php
q***01771 小时前
Java进阶学习之路
java·开发语言·学习