python3自帶的包用起來非常復雜,使用三方包Requests可以方便的發請求。
安裝三方包
pip3 install requests
發post請求
# 向釘釘群發消息
url = "https://oapi.dingtalk.com/robot/send?access_token=edd236299cd610ec989071f66e1abc5cb20c7ebd3613bd95a387b604fdb61e21000"
headers = {"Content-type": "application/json"}
paramsDic = {'msgtype': 'text',
'text': {'content':'我是打包機器人!'}}
d = json.dumps(paramsDic)
resp = requests.post(url,data=d,headers=headers)
print(resp)