import requests url = "https://oapi.dingtalk.com/robot/send?access_token=2add07f31eb0245fa45eed86101253363813b5e70c4d55d0aeb0df2f8b421372" def sendDingMsg(error_type, error_message): # 'Content-Type' => 'application/json' headers = { "Content-Type": "application/json" } data = { "text": { "content": f"【拍照机】异常-{error_type}\n{error_message}" }, "msgtype": "text" } requests.post(url, json=data, headers=headers)