參考官方文檔https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq
#coding=utf8 import requests import json url='https://oapi.dingtalk.com/robot/send?access_token=。。。' # data= {"actionCard": { # "title": "虛擬機數量監控", # "text": "沒有虛擬機在運行哦", # "hideAvatar": "0", # "btnOrientation": "0", # "btns": [ # { # "title": "去關閉", # "actionURL": "。。。" # } # ] # }, # "msgtype": "actionCard"} data={"msgtype": "text", "text": { "content": "今日虛擬機數量:0,如需關閉請登錄。。。" } } header={'Content-Type': 'application/json'} data=json.dumps(data,encoding='utf8') res=requests.post(url,data=data,headers=header) print res.text